CheckJobMapper.xml 58 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272
  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},'%') or
  220. sbinfo.zbh like concat('%',#{keyword},'%') )
  221. </if>
  222. <if test="zbh != null and zbh != ''">
  223. and sbinfo.zbh = #{zbh}
  224. </if>
  225. <if test="sbLevel != null and sbLevel != ''">
  226. and sbinfo.level = #{sbLevel}
  227. </if>
  228. <if test="typeId != null and typeId != ''">
  229. and sbinfo.type_id = #{typeId}
  230. </if>
  231. <if test="typeIdList != null and typeIdList.size > 0">
  232. AND sbinfo.type_id in
  233. <foreach item="item" index="index" collection="typeIdList" open="(" close=")" separator=",">
  234. #{item}
  235. </foreach>
  236. </if>
  237. <if test="periodType != null and periodType != ''">
  238. and standard.period_type = #{periodType}
  239. </if>
  240. <if test="standardLevel != null and standardLevel != ''">
  241. and standard.level = #{standardLevel}
  242. </if>
  243. <if test="standardLevelList != null and standardLevelList.size > 0">
  244. AND standard.level in
  245. <foreach item="item" index="index" collection="standardLevelList" open="(" close=")" separator=",">
  246. #{item}
  247. </foreach>
  248. </if>
  249. <if test="checkUserId != null and checkUserId != ''">
  250. and (
  251. checkjob.check_user_id = #{checkUserId}
  252. <if test="checkDeptIds != null and checkDeptIds.size() > 0">
  253. OR (checkjob.check_dept_id IS NOT NULL AND checkjob.check_dept_id IN
  254. <foreach item="deptId" collection="checkDeptIds" open="(" close=")" separator=",">
  255. #{deptId}
  256. </foreach>)
  257. </if>
  258. )
  259. </if>
  260. <if test="checkDeptId != null and checkDeptId != ''">
  261. and checkjob.check_dept_id = #{checkDeptId}
  262. </if>
  263. <if test="batchDeptId != null and batchDeptId != ''">
  264. and (
  265. EXISTS (
  266. SELECT 1 FROM t_sys_dept_relation dr_bd
  267. WHERE dr_bd.ancestor = #{batchDeptId} AND dr_bd.descendant = checkjob.check_dept_id
  268. )
  269. OR EXISTS (
  270. SELECT 1 FROM t_sys_user_dept sud_bd
  271. INNER JOIN t_sys_dept_relation dr_bd2 ON dr_bd2.descendant = sud_bd.dept_id
  272. WHERE dr_bd2.ancestor = #{batchDeptId} AND sud_bd.user_id = checkjob.check_user_id
  273. )
  274. )
  275. </if>
  276. <if test="type != null and type != ''">
  277. and checkjob.type = #{type}
  278. </if>
  279. <if test="searchStartTime != null and ( status==null or status==1 or status==2)">
  280. and checkjob.start_time <![CDATA[ >= ]]> date_format(#{searchStartTime},'%Y-%m-%d')
  281. </if>
  282. <if test="searchEndTime != null and (status==null or status==1 or status==2)">
  283. and checkjob.start_time <![CDATA[ <= ]]> #{searchEndTime}
  284. </if>
  285. <if test="searchStartTime != null and status!=null and status==3">
  286. and checkjob.actual_start_time <![CDATA[ >= ]]> #{searchStartTime}
  287. </if>
  288. <if test="searchEndTime != null and status!=null and status==3">
  289. and checkjob.actual_start_time <![CDATA[ <= ]]> #{searchEndTime}
  290. </if>
  291. <if test="statusList != null and statusList.size > 0">
  292. AND checkjob.status in
  293. <foreach item="item" index="index" collection="statusList" open="(" close=")" separator=",">
  294. #{item}
  295. </foreach>
  296. </if>
  297. <if test="checkUserName != null and checkUserName != ''">
  298. and (
  299. u.real_name like concat('%',#{checkUserName},'%')
  300. OR (
  301. checkjob.check_dept_id IS NOT NULL
  302. AND EXISTS (
  303. SELECT 1
  304. FROM t_sys_user su
  305. INNER JOIN t_sys_user_dept sud ON sud.user_id = su.user_id
  306. INNER JOIN t_sys_dept_relation dr ON dr.descendant = sud.dept_id
  307. WHERE su.real_name like concat('%',#{checkUserName},'%')
  308. AND dr.ancestor = checkjob.check_dept_id
  309. )
  310. )
  311. )
  312. </if>
  313. <if test="actualUser != null and actualUser != ''">
  314. and checkjob.actual_user like concat('%',#{actualUser},'%')
  315. </if>
  316. <if test="positionId!=null and positionId!=''">
  317. and sbinfo.position_id = #{positionId}
  318. </if>
  319. <if test="periodTypeList != null and periodTypeList.size > 0">
  320. AND standard.period_type in
  321. <foreach item="item" index="index" collection="periodTypeList" open="(" close=")" separator=",">
  322. #{item}
  323. </foreach>
  324. </if>
  325. <if test="sbLevelList != null and sbLevelList.size > 0">
  326. AND sbinfo.level in
  327. <foreach item="item" index="index" collection="sbLevelList" open="(" close=")" separator=",">
  328. #{item}
  329. </foreach>
  330. </if>
  331. <if test="sbNotStatus!=null">
  332. and sbinfo.status !=#{sbNotStatus}
  333. </if>
  334. </sql>
  335. <!-- 子查询专用的条件片段,使用 checkjob_inner 等别名 -->
  336. <sql id="List_Condition_Inner">
  337. <if test="id != null and id != ''">
  338. and checkjob_inner.id = #{id}
  339. </if>
  340. <if test="receiveOvertime != null">
  341. and checkjob_inner.receive_overtime = #{receiveOvertime}
  342. </if>
  343. <if test="planId != null and planId != ''">
  344. and checkjob_inner.plan_id = #{planId}
  345. </if>
  346. <if test="sbId != null and sbId != ''">
  347. and checkjob_inner.sb_id = #{sbId}
  348. </if>
  349. <if test="partId != null and partId != ''">
  350. and checkjob_inner.part_id = #{partId}
  351. </if>
  352. <if test="standardId != null and standardId != ''">
  353. and checkjob_inner.standard_id = #{standardId}
  354. </if>
  355. <if test="requirement != null and requirement != ''">
  356. and checkjob_inner.requirement = #{requirement}
  357. </if>
  358. <if test="remark != null and remark != ''">
  359. and checkjob_inner.remark = #{remark}
  360. </if>
  361. <if test="feedback != null and feedback != ''">
  362. and checkjob_inner.feedback = #{feedback}
  363. </if>
  364. <if test="status ==null and startTimeStart != null ">
  365. and checkjob_inner.start_time <![CDATA[>=]]>#{startTimeStart}
  366. </if>
  367. <if test="status ==null and startTimeEnd != null">
  368. and checkjob_inner.start_time <![CDATA[<=]]> #{startTimeEnd}
  369. </if>
  370. <if test="startTime != null">
  371. and checkjob_inner.start_time = #{startTime}
  372. </if>
  373. <if test="endTimeStart != null">
  374. and checkjob_inner.end_time <![CDATA[>=]]>; #{endTimeStart}
  375. </if>
  376. <if test="endTimeEnd != null">
  377. and checkjob_inner.end_time <![CDATA[<=]]> #{endTimeEnd}
  378. </if>
  379. <if test="endTime != null">
  380. and checkjob_inner.end_time = #{endTime}
  381. </if>
  382. <if test="actualStartTimeStart != null">
  383. and checkjob_inner.actual_start_time <![CDATA[>=]]>; #{actualStartTimeStart}
  384. </if>
  385. <if test="actualStartTimeEnd != null">
  386. and checkjob_inner.actual_start_time <![CDATA[<=]]> #{actualStartTimeEnd}
  387. </if>
  388. <if test="actualStartTime != null">
  389. and checkjob_inner.actual_start_time = #{actualStartTime}
  390. </if>
  391. <if test="actualEndTimeStart != null">
  392. and checkjob_inner.actual_end_time <![CDATA[>=]]> #{actualEndTimeStart}
  393. </if>
  394. <if test="actualEndTimeEnd != null">
  395. and checkjob_inner.actual_end_time <![CDATA[<=]]> #{actualEndTimeEnd}
  396. </if>
  397. <if test="actualEndTime != null">
  398. and checkjob_inner.actual_end_time = #{actualEndTime}
  399. </if>
  400. <if test="status != null">
  401. and checkjob_inner.status = #{status}
  402. </if>
  403. <if test="sbStatus != null">
  404. and checkjob_inner.sb_status = #{sbStatus}
  405. </if>
  406. <if test="createdUserId != null and createdUserId != ''">
  407. and checkjob_inner.created_user_id = #{createdUserId}
  408. </if>
  409. <if test="updateUserId != null and updateUserId != ''">
  410. and checkjob_inner.update_user_id = #{updateUserId}
  411. </if>
  412. <if test="createdUserName != null and createdUserName != ''">
  413. and checkjob_inner.created_user_name = #{createdUserName}
  414. </if>
  415. <if test="updateUserName != null and updateUserName != ''">
  416. and checkjob_inner.update_user_name = #{updateUserName}
  417. </if>
  418. <if test="createdTimeStart != null">
  419. and checkjob_inner.created_time <![CDATA[>=]]> #{createdTimeStart}
  420. </if>
  421. <if test="createdTimeEnd != null">
  422. and checkjob_inner.created_time <![CDATA[<=]]> #{createdTimeEnd}
  423. </if>
  424. <if test="createdTime != null">
  425. and checkjob_inner.created_time = #{createdTime}
  426. </if>
  427. <if test="updateTimeStart != null">
  428. and checkjob_inner.update_time <![CDATA[>=]]> #{updateTimeStart}
  429. </if>
  430. <if test="updateTimeEnd != null">
  431. and checkjob_inner.update_time <![CDATA[<=]]> #{updateTimeEnd}
  432. </if>
  433. <if test="updateTime != null">
  434. and checkjob_inner.update_time = #{updateTime}
  435. </if>
  436. <if test="keyword != null and keyword != ''">
  437. and (
  438. standard_inner.no like concat('%',#{keyword},'%') or
  439. sbinfo_inner.name like concat('%',#{keyword},'%') or
  440. sbinfo_inner.no like concat('%',#{keyword},'%') or
  441. sbinfo_inner.zbh like concat('%',#{keyword},'%') )
  442. </if>
  443. <if test="zbh != null and zbh != ''">
  444. and sbinfo_inner.zbh = #{zbh}
  445. </if>
  446. <if test="sbLevel != null and sbLevel != ''">
  447. and sbinfo_inner.level = #{sbLevel}
  448. </if>
  449. <if test="typeId != null and typeId != ''">
  450. and sbinfo_inner.type_id = #{typeId}
  451. </if>
  452. <if test="typeIdList != null and typeIdList.size > 0">
  453. AND sbinfo_inner.type_id in
  454. <foreach item="item" index="index" collection="typeIdList" open="(" close=")" separator=",">
  455. #{item}
  456. </foreach>
  457. </if>
  458. <if test="periodType != null and periodType != ''">
  459. and standard_inner.period_type = #{periodType}
  460. </if>
  461. <if test="standardLevel != null and standardLevel != ''">
  462. and standard_inner.level = #{standardLevel}
  463. </if>
  464. <if test="standardLevelList != null and standardLevelList.size > 0">
  465. AND standard_inner.level in
  466. <foreach item="item" index="index" collection="standardLevelList" open="(" close=")" separator=",">
  467. #{item}
  468. </foreach>
  469. </if>
  470. <if test="checkUserId != null and checkUserId != ''">
  471. and (
  472. checkjob_inner.check_user_id = #{checkUserId}
  473. <if test="checkDeptIds != null and checkDeptIds.size() > 0">
  474. OR (checkjob_inner.check_dept_id IS NOT NULL AND checkjob_inner.check_dept_id IN
  475. <foreach item="deptId" collection="checkDeptIds" open="(" close=")" separator=",">
  476. #{deptId}
  477. </foreach>)
  478. </if>
  479. )
  480. </if>
  481. <if test="checkDeptId != null and checkDeptId != ''">
  482. and checkjob_inner.check_dept_id = #{checkDeptId}
  483. </if>
  484. <if test="batchDeptId != null and batchDeptId != ''">
  485. and (
  486. EXISTS (
  487. SELECT 1 FROM t_sys_dept_relation dr_bd
  488. WHERE dr_bd.ancestor = #{batchDeptId} AND dr_bd.descendant = checkjob_inner.check_dept_id
  489. )
  490. OR EXISTS (
  491. SELECT 1 FROM t_sys_user_dept sud_bd
  492. INNER JOIN t_sys_dept_relation dr_bd2 ON dr_bd2.descendant = sud_bd.dept_id
  493. WHERE dr_bd2.ancestor = #{batchDeptId} AND sud_bd.user_id = checkjob_inner.check_user_id
  494. )
  495. )
  496. </if>
  497. <if test="type != null and type != ''">
  498. and checkjob_inner.type = #{type}
  499. </if>
  500. <if test="searchStartTime != null and ( status==null or status==1 or status==2)">
  501. and checkjob_inner.start_time <![CDATA[ >= ]]> date_format(#{searchStartTime},'%Y-%m-%d')
  502. </if>
  503. <if test="searchEndTime != null and (status==null or status==1 or status==2)">
  504. and checkjob_inner.start_time <![CDATA[ <= ]]> #{searchEndTime}
  505. </if>
  506. <if test="searchStartTime != null and status!=null and status==3">
  507. and checkjob_inner.actual_start_time <![CDATA[ >= ]]> #{searchStartTime}
  508. </if>
  509. <if test="searchEndTime != null and status!=null and status==3">
  510. and checkjob_inner.actual_start_time <![CDATA[ <= ]]> #{searchEndTime}
  511. </if>
  512. <if test="statusList != null and statusList.size > 0">
  513. AND checkjob_inner.status in
  514. <foreach item="item" index="index" collection="statusList" open="(" close=")" separator=",">
  515. #{item}
  516. </foreach>
  517. </if>
  518. <if test="checkUserName != null and checkUserName != ''">
  519. and (
  520. u.real_name like concat('%',#{checkUserName},'%')
  521. OR (
  522. checkjob_inner.check_dept_id IS NOT NULL
  523. AND EXISTS (
  524. SELECT 1
  525. FROM t_sys_user su
  526. INNER JOIN t_sys_user_dept sud ON sud.user_id = su.user_id
  527. INNER JOIN t_sys_dept_relation dr ON dr.descendant = sud.dept_id
  528. WHERE su.real_name like concat('%',#{checkUserName},'%')
  529. AND dr.ancestor = checkjob_inner.check_dept_id
  530. )
  531. )
  532. )
  533. </if>
  534. <if test="actualUser != null and actualUser != ''">
  535. and checkjob_inner.actual_user like concat('%',#{actualUser},'%')
  536. </if>
  537. <if test="positionId!=null and positionId!=''">
  538. and sbinfo_inner.position_id = #{positionId}
  539. </if>
  540. <if test="periodTypeList != null and periodTypeList.size > 0">
  541. AND standard_inner.period_type in
  542. <foreach item="item" index="index" collection="periodTypeList" open="(" close=")" separator=",">
  543. #{item}
  544. </foreach>
  545. </if>
  546. <if test="sbLevelList != null and sbLevelList.size > 0">
  547. AND sbinfo_inner.level in
  548. <foreach item="item" index="index" collection="sbLevelList" open="(" close=")" separator=",">
  549. #{item}
  550. </foreach>
  551. </if>
  552. <if test="sbNotStatus!=null">
  553. and sbinfo_inner.status !=#{sbNotStatus}
  554. </if>
  555. </sql>
  556. <select id="selectList" parameterType="com.platform.dao.dto.check.CheckJobDTO"
  557. resultMap="CheckJobVOMap">
  558. select
  559. checkjob.id as id,
  560. checkjob.plan_id as plan_id,
  561. checkjob.name as name,
  562. checkjob.type as type,
  563. checkjob.hours as hours,
  564. checkjob.miles as miles,
  565. checkjob.sb_id as sb_id,
  566. checkjob.part_id as part_id,
  567. checkjob.standard_id as standard_id,
  568. checkjob.start_time as start_time,
  569. checkjob.end_time as end_time,
  570. checkjob.actual_start_time as actual_start_time,
  571. checkjob.actual_end_time as actual_end_time,
  572. checkjob.requirement as requirement,
  573. checkjob.remark as remark,
  574. checkjob.feedback as feedback,
  575. checkjob.status as status,
  576. checkjob.sb_status as sb_status,
  577. checkjob.check_user_id as check_user_id,
  578. checkjob.check_dept_id as check_dept_id,
  579. checkjob.created_user_id as created_user_id,
  580. checkjob.update_user_id as update_user_id,
  581. checkjob.created_user_name as created_user_name,
  582. checkjob.update_user_name as update_user_name,
  583. checkjob.created_time as created_time,
  584. checkjob.update_time as update_time,
  585. checkjob.standard_hours as standard_hours,
  586. checkjob.real_hours as real_hours,
  587. checkjob.actual_user as actual_user,
  588. checkjob.receive_overtime as receive_overtime,
  589. checkjob.con_task as con_task,
  590. u.real_name as checkUserName,
  591. dept.name as checkDeptName,
  592. sbinfo.name as sbName,
  593. sbinfo.no as sbNo,
  594. sbinfo.level as sbLevel,
  595. sbinfo.id as sbInfoId,
  596. partinfo.name as partName,
  597. standard.no as standardNo,
  598. standard.name as standardName,
  599. standard.level as standardLevel,
  600. standard.period as period,
  601. standard.period_type as periodType,
  602. position.id as positionId,
  603. position.name as positionName,
  604. cr.id as requirement_id,
  605. cr.std_name as std_name,
  606. cr.scope as scope,
  607. cr.type as requirement_type,
  608. cr.method as requirement_method,
  609. cr.sb_type as requirement_sb_type,
  610. cr.check_level as requirement_check_level,
  611. cr.manage_item as requirement_manage_item,
  612. cr.check_item as requirement_check_item,
  613. cr.content as requirement_content,
  614. cr.period as requirement_period,
  615. sbtype.name as requirement_sb_type_name,
  616. cr.remark as requirement_remark,
  617. cr.created_user_name as requirement_created_user_name,
  618. cr.created_time as requirement_created_time,
  619. cr.update_user_name as requirement_update_user_name,
  620. cr.update_time as requirement_update_time,
  621. cr.status as requirement_status
  622. from t_check_job as checkjob
  623. left join t_sb_info sbinfo on sbinfo.id = checkjob.sb_id
  624. left join t_part_info partinfo on partinfo.id = checkjob.part_id
  625. left join t_check_standard standard on standard.id = checkjob.standard_id
  626. left join t_sys_user u on checkjob.check_user_id = u.user_id
  627. left join t_sys_dept dept on checkjob.check_dept_id = dept.dept_id
  628. left join t_sb_position position on position.id = sbinfo.position_id
  629. left join t_check_standard_requirement csr on csr.standard_id = standard.id
  630. left join t_check_requirement cr on cr.id = csr.requirement_id
  631. left join t_sb_type sbtype on sbtype.id = cr.sb_type
  632. WHERE checkjob.id IN (
  633. SELECT job_id FROM (
  634. SELECT checkjob_inner.id as job_id
  635. FROM t_check_job checkjob_inner
  636. LEFT JOIN t_sb_info sbinfo_inner ON sbinfo_inner.id = checkjob_inner.sb_id
  637. LEFT JOIN t_check_standard standard_inner ON standard_inner.id = checkjob_inner.standard_id
  638. LEFT JOIN t_sys_user u ON checkjob_inner.check_user_id = u.user_id
  639. <where>
  640. <include refid="List_Condition_Inner"/>
  641. </where>
  642. ORDER BY
  643. checkjob_inner.status asc,
  644. <if test="status==null or status==1 or status==2">
  645. checkjob_inner.start_time asc,
  646. </if>
  647. sbinfo_inner.level asc,
  648. sbinfo_inner.no asc,
  649. standard_inner.period_type asc,
  650. standard_inner.period asc
  651. ) as tmp
  652. )
  653. Order By
  654. checkjob.status asc,
  655. <if test="status==null or status==1 or status==2">
  656. checkjob.start_time asc,
  657. </if>
  658. sbinfo.level asc,
  659. sbinfo.no asc,
  660. standard.period_type asc,
  661. standard.period asc
  662. </select>
  663. <select id="selectList2" parameterType="com.platform.dao.dto.check.CheckJobDTO"
  664. resultMap="CheckJobVOMap">
  665. select
  666. checkjob.id as id,
  667. checkjob.plan_id as plan_id,
  668. checkjob.name as name,
  669. checkjob.type as type,
  670. checkjob.hours as hours,
  671. checkjob.miles as miles,
  672. checkjob.sb_id as sb_id,
  673. checkjob.part_id as part_id,
  674. checkjob.standard_id as standard_id,
  675. checkjob.start_time as start_time,
  676. checkjob.end_time as end_time,
  677. checkjob.actual_start_time as actual_start_time,
  678. checkjob.actual_end_time as actual_end_time,
  679. checkjob.requirement as requirement,
  680. checkjob.remark as remark,
  681. checkjob.feedback as feedback,
  682. checkjob.status as status,
  683. checkjob.sb_status as sb_status,
  684. checkjob.check_user_id as check_user_id,
  685. checkjob.check_dept_id as check_dept_id,
  686. checkjob.created_user_id as created_user_id,
  687. checkjob.update_user_id as update_user_id,
  688. checkjob.created_user_name as created_user_name,
  689. checkjob.update_user_name as update_user_name,
  690. checkjob.created_time as created_time,
  691. checkjob.update_time as update_time,
  692. checkjob.standard_hours as standard_hours,
  693. checkjob.real_hours as real_hours,
  694. checkjob.actual_user as actual_user,
  695. checkjob.receive_overtime as receive_overtime,
  696. checkjob.con_task as con_task,
  697. u.real_name as checkUserName,
  698. dept.name as checkDeptName,
  699. sbinfo.name as sbName,
  700. sbinfo.no as sbNo,
  701. sbinfo.level as sbLevel,
  702. sbinfo.id as sbInfoId,
  703. partinfo.name as partName,
  704. standard.no as standardNo,
  705. standard.name as standardName,
  706. standard.level as standardLevel,
  707. standard.period as period,
  708. standard.period_type as periodType,
  709. position.id as positionId,
  710. position.name as positionName,
  711. <!-- 保养要求相关字段 -->
  712. cr.id as requirement_id,
  713. cr.std_name as std_name,
  714. cr.scope as scope,
  715. cr.type as requirement_type,
  716. cr.method as requirement_method,
  717. cr.sb_type as requirement_sb_type,
  718. cr.check_level as requirement_check_level,
  719. cr.manage_item as requirement_manage_item,
  720. cr.check_item as requirement_check_item,
  721. cr.content as requirement_content,
  722. cr.period as requirement_period,
  723. sbtype.name as requirement_sb_type_name,
  724. cr.remark as requirement_remark,
  725. cr.created_user_name as requirement_created_user_name,
  726. cr.created_time as requirement_created_time,
  727. cr.update_user_name as requirement_update_user_name,
  728. cr.update_time as requirement_update_time,
  729. cr.status as requirement_status
  730. from t_check_job as checkjob
  731. left join t_sb_info sbinfo on sbinfo.id = checkjob.sb_id
  732. left join t_part_info partinfo on partinfo.id = checkjob.part_id
  733. left join t_check_standard standard on standard.id = checkjob.standard_id
  734. left join t_sys_user u on checkjob.check_user_id = u.user_id
  735. left join t_sys_dept dept on checkjob.check_dept_id = dept.dept_id
  736. left join t_sb_position position on position.id = sbinfo.position_id
  737. <!-- 关联保养要求表 -->
  738. left join t_check_standard_requirement csr on csr.standard_id = standard.id
  739. left join t_check_requirement cr on cr.id = csr.requirement_id and cr.status = 1
  740. left join t_sb_type sbtype on sbtype.id = cr.sb_type
  741. <where>
  742. <include refid="List_Condition"/>
  743. </where>
  744. </select>
  745. <select id="getScreenCountByTime" parameterType="com.platform.dao.dto.check.CheckJobDTO"
  746. resultType="com.platform.dao.vo.query.check.CheckJobVO">
  747. select count(checkjob.id) as countNum
  748. from t_check_job as checkjob
  749. <where>
  750. <if test="searchStartTime != null">
  751. and checkjob.start_time <![CDATA[ >= ]]> #{searchStartTime}
  752. </if>
  753. <if test="searchEndTime != null">
  754. and checkjob.start_time <![CDATA[ <= ]]> #{searchEndTime}
  755. </if>
  756. <if test="status != null">
  757. and checkjob.status = #{status}
  758. </if>
  759. </where>
  760. </select>
  761. <select id="countByCondition" parameterType="com.platform.dao.dto.check.CheckJobDTO"
  762. resultType="long">
  763. select count(DISTINCT checkjob.id)
  764. from t_check_job checkjob
  765. LEFT JOIN t_sb_info sbinfo ON sbinfo.id = checkjob.sb_id
  766. LEFT JOIN t_check_standard standard ON standard.id = checkjob.standard_id
  767. LEFT JOIN t_sys_user u ON checkjob.check_user_id = u.user_id
  768. <where>
  769. <include refid="List_Condition"/>
  770. </where>
  771. </select>
  772. <select id="selectDetail" resultType="com.platform.dao.vo.query.check.CheckJobVO">
  773. select checkjob.id as id,
  774. checkjob.plan_id as plan_id,
  775. checkjob.name as name,
  776. checkjob.type as type,
  777. checkjob.hours as hours,
  778. checkjob.miles as miles,
  779. checkjob.sb_id as sb_id,
  780. checkjob.part_id as part_id,
  781. checkjob.standard_id as standard_id,
  782. checkjob.start_time as start_time,
  783. checkjob.end_time as end_time,
  784. checkjob.actual_start_time as actual_start_time,
  785. checkjob.actual_end_time as actual_end_time,
  786. checkjob.requirement as requirement,
  787. checkjob.remark as remark,
  788. checkjob.feedback as feedback,
  789. checkjob.status as status,
  790. checkjob.sb_status as sb_status,
  791. checkjob.check_user_id as check_user_id,
  792. checkjob.check_dept_id as check_dept_id,
  793. checkjob.created_user_id as created_user_id,
  794. checkjob.update_user_id as update_user_id,
  795. checkjob.created_user_name as created_user_name,
  796. checkjob.update_user_name as update_user_name,
  797. checkjob.created_time as created_time,
  798. checkjob.update_time as update_time,
  799. checkjob.standard_hours as standard_hours,
  800. checkjob.real_hours as real_hours,
  801. checkjob.actual_user as actual_user,
  802. checkjob.receive_overtime as receive_overtime,
  803. checkjob.con_task as con_task,
  804. u.real_name as checkUserName,
  805. dept.name as checkDeptName,
  806. sbinfo.name sbName,
  807. sbinfo.no sbNo,
  808. sbinfo.level sbLevel,
  809. partinfo.name partName,
  810. standard.no standardNo,
  811. standard.name standardName,
  812. standard.level standardLevel,
  813. standard.period period,
  814. standard.next_date as nextDate,
  815. standard.period_type periodType,
  816. standard.consumables consumables,
  817. standard.spare_parts spareParts
  818. from t_check_job as checkjob
  819. left join t_sb_info sbinfo on sbinfo.id = checkjob.sb_id
  820. left join t_part_info partinfo on partinfo.id = checkjob.part_id
  821. left join t_check_standard standard on standard.id = checkjob.standard_id
  822. left join t_sys_user u on checkjob.check_user_id = u.user_id
  823. left join t_sys_dept dept on checkjob.check_dept_id = dept.dept_id
  824. where checkjob.id = #{id}
  825. </select>
  826. <select id="getNotFinishNumByDTO" resultType="java.lang.Integer">
  827. select count(checkjob.id)
  828. from t_check_job as checkjob
  829. left join t_sb_info sbinfo on sbinfo.id = checkjob.sb_id
  830. left join t_part_info partinfo on partinfo.id = checkjob.part_id
  831. left join t_check_standard standard on standard.id = checkjob.standard_id
  832. left join t_sys_user u on checkjob.check_user_id = u.user_id
  833. <where>
  834. <include refid="List_Condition"/>
  835. </where>
  836. </select>
  837. <select id="selectLastJob" parameterType="com.platform.dao.dto.check.CheckJobDTO"
  838. resultType="com.platform.dao.vo.query.check.CheckJobVO">
  839. select checkjob.id as id,
  840. checkjob.plan_id as plan_id,
  841. checkjob.name as name,
  842. checkjob.type as type,
  843. checkjob.hours as hours,
  844. checkjob.miles as miles,
  845. checkjob.sb_id as sb_id,
  846. checkjob.part_id as part_id,
  847. checkjob.standard_id as standard_id,
  848. checkjob.start_time as start_time,
  849. checkjob.end_time as end_time,
  850. checkjob.actual_start_time as actual_start_time,
  851. checkjob.actual_end_time as actual_end_time,
  852. checkjob.requirement as requirement,
  853. checkjob.remark as remark,
  854. checkjob.feedback as feedback,
  855. checkjob.status as status,
  856. checkjob.sb_status as sb_status,
  857. checkjob.check_user_id as check_user_id,
  858. checkjob.check_dept_id as check_dept_id,
  859. checkjob.created_user_id as created_user_id,
  860. checkjob.update_user_id as update_user_id,
  861. checkjob.created_user_name as created_user_name,
  862. checkjob.update_user_name as update_user_name,
  863. checkjob.created_time as created_time,
  864. checkjob.update_time as update_time,
  865. checkjob.standard_hours as standard_hours,
  866. checkjob.real_hours as real_hours,
  867. checkjob.actual_user as actual_user,
  868. checkjob.receive_overtime as receive_overtime,
  869. checkjob.con_task as con_task
  870. from t_check_job as checkjob
  871. where checkjob.sb_id = #{sbId}
  872. and checkjob.standard_id = #{standardId}
  873. order by checkjob.created_time desc limit 1
  874. </select>
  875. <update id="updateBatch" parameterType="java.util.List">
  876. <foreach collection="list" item="item" index="index" open="" close="" separator=";">
  877. update t_check_job
  878. <set>
  879. <if test="item.receiveOvertime != null">
  880. receive_overtime = #{item.receiveOvertime}
  881. </if>
  882. <if test="item.startTime != null">
  883. start_time = #{item.startTime}
  884. </if>
  885. </set>
  886. where id = #{item.id}
  887. </foreach>
  888. </update>
  889. <update id="updateBatchByDelStandard" parameterType="com.platform.dao.entity.check.CheckJob">
  890. update t_check_job
  891. <set>
  892. status = 3,
  893. remark = #{remark}
  894. </set>
  895. where standard_id = #{standardId}
  896. and status != 3
  897. </update>
  898. <select id="selectListByDate" parameterType="com.platform.dao.dto.check.CheckJobDTO"
  899. resultType="com.platform.dao.vo.query.check.CheckJobVO">
  900. select checkjob.id as id,
  901. checkjob.plan_id as plan_id,
  902. checkjob.name as name,
  903. checkjob.type as type,
  904. checkjob.hours as hours,
  905. checkjob.miles as miles,
  906. checkjob.sb_id as sb_id,
  907. checkjob.part_id as part_id,
  908. checkjob.standard_id as standard_id,
  909. checkjob.start_time as start_time,
  910. checkjob.end_time as end_time,
  911. checkjob.actual_start_time as actual_start_time,
  912. checkjob.actual_end_time as actual_end_time,
  913. checkjob.requirement as requirement,
  914. checkjob.remark as remark,
  915. checkjob.feedback as feedback,
  916. checkjob.status as status,
  917. checkjob.sb_status as sb_status,
  918. checkjob.check_user_id as check_user_id,
  919. checkjob.check_dept_id as check_dept_id,
  920. checkjob.created_user_id as created_user_id,
  921. checkjob.update_user_id as update_user_id,
  922. checkjob.created_user_name as created_user_name,
  923. checkjob.update_user_name as update_user_name,
  924. checkjob.created_time as created_time,
  925. checkjob.update_time as update_time,
  926. checkjob.standard_hours as standard_hours,
  927. checkjob.real_hours as real_hours,
  928. checkjob.actual_user as actual_user,
  929. checkjob.receive_overtime as receive_overtime,
  930. checkjob.con_task as con_task
  931. from t_check_job as checkjob
  932. <where>
  933. <if test="status != null">
  934. and checkjob.status = #{status}
  935. </if>
  936. <if test="startTimeEnd != null">
  937. and checkjob.start_time <![CDATA[ <= ]]> #{startTimeEnd}
  938. </if>
  939. </where>
  940. </select>
  941. <!-- 分页查询任务ID列表 -->
  942. <select id="selectJobIdPage" parameterType="com.platform.dao.dto.check.CheckJobDTO"
  943. resultType="java.lang.String">
  944. SELECT checkjob_inner.id
  945. FROM t_check_job checkjob_inner
  946. LEFT JOIN t_sb_info sbinfo_inner ON sbinfo_inner.id = checkjob_inner.sb_id
  947. LEFT JOIN t_check_standard standard_inner ON standard_inner.id = checkjob_inner.standard_id
  948. LEFT JOIN t_sys_user u ON checkjob_inner.check_user_id = u.user_id
  949. <where>
  950. <include refid="List_Condition_Inner"/>
  951. </where>
  952. </select>
  953. <!-- 根据ID列表查询完整数据 -->
  954. <select id="selectListByIds" parameterType="com.platform.dao.dto.check.CheckJobDTO"
  955. resultMap="CheckJobVOMap">
  956. select
  957. checkjob.id as id,
  958. checkjob.plan_id as plan_id,
  959. checkjob.name as name,
  960. checkjob.type as type,
  961. checkjob.hours as hours,
  962. checkjob.miles as miles,
  963. checkjob.sb_id as sb_id,
  964. checkjob.part_id as part_id,
  965. checkjob.standard_id as standard_id,
  966. checkjob.start_time as start_time,
  967. checkjob.end_time as end_time,
  968. checkjob.actual_start_time as actual_start_time,
  969. checkjob.actual_end_time as actual_end_time,
  970. checkjob.requirement as requirement,
  971. checkjob.remark as remark,
  972. checkjob.feedback as feedback,
  973. checkjob.status as status,
  974. checkjob.sb_status as sb_status,
  975. checkjob.check_user_id as check_user_id,
  976. checkjob.check_dept_id as check_dept_id,
  977. checkjob.created_user_id as created_user_id,
  978. checkjob.update_user_id as update_user_id,
  979. checkjob.created_user_name as created_user_name,
  980. checkjob.update_user_name as update_user_name,
  981. checkjob.created_time as created_time,
  982. checkjob.update_time as update_time,
  983. checkjob.standard_hours as standard_hours,
  984. checkjob.real_hours as real_hours,
  985. checkjob.actual_user as actual_user,
  986. checkjob.receive_overtime as receive_overtime,
  987. checkjob.con_task as con_task,
  988. u.real_name as checkUserName,
  989. dept.name as checkDeptName,
  990. sbinfo.name as sbName,
  991. sbinfo.no as sbNo,
  992. sbinfo.level as sbLevel,
  993. sbinfo.id as sbInfoId,
  994. partinfo.name as partName,
  995. standard.no as standardNo,
  996. standard.name as standardName,
  997. standard.level as standardLevel,
  998. standard.period as period,
  999. standard.period_type as periodType,
  1000. position.id as positionId,
  1001. position.name as positionName,
  1002. cr.id as requirement_id,
  1003. cr.std_name as std_name,
  1004. cr.scope as scope,
  1005. cr.type as requirement_type,
  1006. cr.method as requirement_method,
  1007. cr.sb_type as requirement_sb_type,
  1008. cr.check_level as requirement_check_level,
  1009. cr.manage_item as requirement_manage_item,
  1010. cr.check_item as requirement_check_item,
  1011. cr.content as requirement_content,
  1012. cr.period as requirement_period,
  1013. sbtype.name as requirement_sb_type_name,
  1014. cr.remark as requirement_remark,
  1015. cr.created_user_name as requirement_created_user_name,
  1016. cr.created_time as requirement_created_time,
  1017. cr.update_user_name as requirement_update_user_name,
  1018. cr.update_time as requirement_update_time,
  1019. cr.status as requirement_status
  1020. from t_check_job as checkjob
  1021. left join t_sb_info sbinfo on sbinfo.id = checkjob.sb_id
  1022. left join t_part_info partinfo on partinfo.id = checkjob.part_id
  1023. left join t_check_standard standard on standard.id = checkjob.standard_id
  1024. left join t_sys_user u on checkjob.check_user_id = u.user_id
  1025. left join t_sys_dept dept on checkjob.check_dept_id = dept.dept_id
  1026. left join t_sb_position position on position.id = sbinfo.position_id
  1027. left join t_check_standard_requirement csr on csr.standard_id = standard.id
  1028. left join t_check_requirement cr on cr.id = csr.requirement_id
  1029. left join t_sb_type sbtype on sbtype.id = cr.sb_type
  1030. WHERE checkjob.id IN
  1031. <foreach item="item" index="index" collection="jobIdList" open="(" close=")" separator=",">
  1032. #{item}
  1033. </foreach>
  1034. Order By
  1035. checkjob.status asc,
  1036. <if test="status==null or status==1 or status==2">
  1037. checkjob.start_time asc,
  1038. </if>
  1039. sbinfo.level asc,
  1040. sbinfo.no asc,
  1041. standard.period_type asc,
  1042. standard.period asc
  1043. </select>
  1044. <!-- 根据ID列表查询完整数据2(record=1) -->
  1045. <select id="selectList2ByIds" parameterType="com.platform.dao.dto.check.CheckJobDTO"
  1046. resultMap="CheckJobVOMap">
  1047. select
  1048. checkjob.id as id,
  1049. checkjob.plan_id as plan_id,
  1050. checkjob.name as name,
  1051. checkjob.type as type,
  1052. checkjob.hours as hours,
  1053. checkjob.miles as miles,
  1054. checkjob.sb_id as sb_id,
  1055. checkjob.part_id as part_id,
  1056. checkjob.standard_id as standard_id,
  1057. checkjob.start_time as start_time,
  1058. checkjob.end_time as end_time,
  1059. checkjob.actual_start_time as actual_start_time,
  1060. checkjob.actual_end_time as actual_end_time,
  1061. checkjob.requirement as requirement,
  1062. checkjob.remark as remark,
  1063. checkjob.feedback as feedback,
  1064. checkjob.status as status,
  1065. checkjob.sb_status as sb_status,
  1066. checkjob.check_user_id as check_user_id,
  1067. checkjob.check_dept_id as check_dept_id,
  1068. checkjob.created_user_id as created_user_id,
  1069. checkjob.update_user_id as update_user_id,
  1070. checkjob.created_user_name as created_user_name,
  1071. checkjob.update_user_name as update_user_name,
  1072. checkjob.created_time as created_time,
  1073. checkjob.update_time as update_time,
  1074. checkjob.standard_hours as standard_hours,
  1075. checkjob.real_hours as real_hours,
  1076. checkjob.actual_user as actual_user,
  1077. checkjob.receive_overtime as receive_overtime,
  1078. checkjob.con_task as con_task,
  1079. u.real_name as checkUserName,
  1080. dept.name as checkDeptName,
  1081. sbinfo.name as sbName,
  1082. sbinfo.no as sbNo,
  1083. sbinfo.level as sbLevel,
  1084. sbinfo.id as sbInfoId,
  1085. partinfo.name as partName,
  1086. standard.no as standardNo,
  1087. standard.name as standardName,
  1088. standard.level as standardLevel,
  1089. standard.period as period,
  1090. standard.period_type as periodType,
  1091. position.id as positionId,
  1092. position.name as positionName,
  1093. cr.id as requirement_id,
  1094. cr.std_name as std_name,
  1095. cr.scope as scope,
  1096. cr.type as requirement_type,
  1097. cr.method as requirement_method,
  1098. cr.sb_type as requirement_sb_type,
  1099. cr.check_level as requirement_check_level,
  1100. cr.manage_item as requirement_manage_item,
  1101. cr.check_item as requirement_check_item,
  1102. cr.content as requirement_content,
  1103. cr.period as requirement_period,
  1104. sbtype.name as requirement_sb_type_name,
  1105. cr.remark as requirement_remark,
  1106. cr.created_user_name as requirement_created_user_name,
  1107. cr.created_time as requirement_created_time,
  1108. cr.update_user_name as requirement_update_user_name,
  1109. cr.update_time as requirement_update_time,
  1110. cr.status as requirement_status
  1111. from t_check_job as checkjob
  1112. left join t_sb_info sbinfo on sbinfo.id = checkjob.sb_id
  1113. left join t_part_info partinfo on partinfo.id = checkjob.part_id
  1114. left join t_check_standard standard on standard.id = checkjob.standard_id
  1115. left join t_sys_user u on checkjob.check_user_id = u.user_id
  1116. left join t_sys_dept dept on checkjob.check_dept_id = dept.dept_id
  1117. left join t_sb_position position on position.id = sbinfo.position_id
  1118. left join t_check_standard_requirement csr on csr.standard_id = standard.id
  1119. left join t_check_requirement cr on cr.id = csr.requirement_id and cr.status = 1
  1120. left join t_sb_type sbtype on sbtype.id = cr.sb_type
  1121. WHERE checkjob.id IN
  1122. <foreach item="item" index="index" collection="jobIdList" open="(" close=")" separator=",">
  1123. #{item}
  1124. </foreach>
  1125. </select>
  1126. <!-- 查询执行方式为班组、未完成(status != 3)且开始日期不晚于今天(start_time <= CURDATE())的保养任务,用于每日早上9点定时提醒班长:
  1127. 既包含已逾期任务,也包含今天到期但发邮件时仍未完成的任务;未来任务(start_time > 今天)不提醒。
  1128. 注意:start_time 为日期级(LocalDate),用 <= CURDATE() 可覆盖“今天”一整天,勿改成 < CURDATE() 否则会漏掉今天到期的任务 -->
  1129. <select id="selectUnfinishedTeamJobs" resultType="com.platform.dao.vo.query.check.CheckJobVO">
  1130. select
  1131. checkjob.id as id,
  1132. checkjob.name as name,
  1133. checkjob.sb_id as sbId,
  1134. checkjob.standard_id as standardId,
  1135. checkjob.status as status,
  1136. checkjob.check_dept_id as checkDeptId,
  1137. checkjob.start_time as startTime,
  1138. checkjob.end_time as endTime,
  1139. sbinfo.name as sbName,
  1140. sbinfo.no as sbNo,
  1141. dept.name as checkDeptName
  1142. from t_check_job as checkjob
  1143. inner join t_check_standard standard on standard.id = checkjob.standard_id
  1144. left join t_sb_info sbinfo on sbinfo.id = checkjob.sb_id
  1145. left join t_sys_dept dept on checkjob.check_dept_id = dept.dept_id
  1146. where checkjob.type = 2
  1147. and standard.check_user_type = 4
  1148. and checkjob.check_dept_id is not null
  1149. and checkjob.status != 3
  1150. and checkjob.start_time &lt;= CURDATE()
  1151. order by checkjob.check_dept_id asc, sbinfo.no asc
  1152. </select>
  1153. <!-- 显式更新指定标准下某状态任务的执行人字段,允许将 check_user_id / check_dept_id 置空,
  1154. 用于执行人方式在“班组”与“具体人”之间切换时彻底移交任务归属 -->
  1155. <update id="updateJobExecutor">
  1156. update t_check_job
  1157. set check_user_id = #{checkUserId},
  1158. check_dept_id = #{checkDeptId}
  1159. where standard_id = #{standardId}
  1160. and status = #{status}
  1161. </update>
  1162. <!-- 设备近期点检(保养)日历:只查单台设备当月已完成(status=3)的任务,
  1163. 完成日取 actual_end_time,历史数据为空时依次退化为 actual_start_time、end_time(与年度计划表口径一致),
  1164. 不走 selectList 的多表联查(避免脏数据与免登录场景下的额外开销) -->
  1165. <select id="selectSbFinishedJobs" resultType="com.platform.dao.vo.query.check.CheckJobVO">
  1166. select
  1167. checkjob.id as id,
  1168. checkjob.name as name,
  1169. checkjob.type as type,
  1170. checkjob.status as status,
  1171. checkjob.sb_id as sbId,
  1172. checkjob.start_time as startTime,
  1173. checkjob.end_time as endTime,
  1174. checkjob.actual_user as actualUser,
  1175. coalesce(checkjob.actual_end_time, checkjob.actual_start_time, checkjob.end_time) as actualEndTime,
  1176. u.real_name as checkUserName,
  1177. dept.name as checkDeptName,
  1178. standard.name as standardName
  1179. from t_check_job checkjob
  1180. left join t_check_standard standard on standard.id = checkjob.standard_id
  1181. left join t_sys_user u on u.user_id = checkjob.check_user_id
  1182. left join t_sys_dept dept on dept.dept_id = checkjob.check_dept_id
  1183. where checkjob.sb_id = #{sbId}
  1184. and checkjob.status = 3
  1185. and coalesce(checkjob.actual_end_time, checkjob.actual_start_time, checkjob.end_time) <![CDATA[>=]]> #{startTime}
  1186. and coalesce(checkjob.actual_end_time, checkjob.actual_start_time, checkjob.end_time) <![CDATA[<=]]> #{endTime}
  1187. <if test="type != null">
  1188. and checkjob.type = #{type}
  1189. </if>
  1190. order by actualEndTime asc, checkjob.id asc
  1191. </select>
  1192. <!-- 年度保养计划表:以“保养标准(t_check_standard)”为行来源,排除按天(period_type=1)的保养,
  1193. 即使该标准尚未执行任何任务也会显示一行(月份不打勾);
  1194. 当年某设备每月只要有已完成(status=3)的保养任务则该月打勾√ -->
  1195. <select id="selectAnnualPlan" parameterType="com.platform.dao.dto.check.CheckJobDTO"
  1196. resultType="com.platform.dao.vo.query.check.CheckJobAnnualPlanVO">
  1197. select
  1198. sbtype.name as category,
  1199. sbinfo.name as sbName,
  1200. <!-- 保养负责人与任务生成逻辑保持一致:
  1201. 1-使用人取设备保管人(save_user),2-维修人取设备第一维修人(repair_user),
  1202. 3-指定取标准上已绑定的人(保存时=维修人),4-班组取部门 -->
  1203. case standard.check_user_type
  1204. when 1 then su_save.real_name
  1205. when 2 then su_repair.real_name
  1206. when 3 then coalesce(su.real_name, su_repair.real_name)
  1207. when 4 then sdept.name
  1208. else coalesce(su.real_name, sdept.name)
  1209. end as owner,
  1210. count(distinct sbinfo.id) as sbNum,
  1211. max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 1 then '√' else '' end) as month1,
  1212. max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 2 then '√' else '' end) as month2,
  1213. max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 3 then '√' else '' end) as month3,
  1214. max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 4 then '√' else '' end) as month4,
  1215. max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 5 then '√' else '' end) as month5,
  1216. max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 6 then '√' else '' end) as month6,
  1217. max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 7 then '√' else '' end) as month7,
  1218. max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 8 then '√' else '' end) as month8,
  1219. max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 9 then '√' else '' end) as month9,
  1220. max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 10 then '√' else '' end) as month10,
  1221. max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 11 then '√' else '' end) as month11,
  1222. max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 12 then '√' else '' end) as month12
  1223. from t_check_standard standard
  1224. inner join t_sb_info sbinfo on sbinfo.id = standard.sb_id
  1225. left join t_sb_type sbtype on sbtype.id = sbinfo.type_id
  1226. left join t_sys_user su on standard.check_user_id = su.user_id
  1227. left join t_sys_dept sdept on standard.check_dept_id = sdept.dept_id
  1228. left join t_sys_user su_save on sbinfo.save_user = su_save.user_id
  1229. left join t_sys_user su_repair on sbinfo.repair_user = su_repair.user_id
  1230. left join t_check_job job on job.standard_id = standard.id
  1231. and job.status = 3
  1232. <if test="searchYear != null">
  1233. and year(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = #{searchYear}
  1234. </if>
  1235. <where>
  1236. standard.period_type != 1
  1237. <if test="type != null">
  1238. and standard.type = #{type}
  1239. </if>
  1240. </where>
  1241. group by sbtype.name, sbinfo.name,
  1242. case standard.check_user_type
  1243. when 1 then su_save.real_name
  1244. when 2 then su_repair.real_name
  1245. when 3 then coalesce(su.real_name, su_repair.real_name)
  1246. when 4 then sdept.name
  1247. else coalesce(su.real_name, sdept.name)
  1248. end
  1249. order by sbtype.name asc, sbinfo.name asc
  1250. </select>
  1251. </mapper>