WorkStaffAchivesDao.xml 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809
  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.jeeplus.modules.workstaff.dao.WorkStaffAchivesDao">
  4. <sql id="workStaffBasicInfoColumns">
  5. a.id AS "id",
  6. a.create_by AS "createBy.id",
  7. a.create_date AS "createDate",
  8. a.update_by AS "updateBy.id",
  9. a.update_date AS "updateDate",
  10. a.remarks AS "remarks",
  11. a.del_flag AS "delFlag",
  12. a.office_id AS "office.id",
  13. a.company_id AS "company.id",
  14. a.no AS "no",
  15. a.dimission_date AS "dimissionDate",
  16. a.workEnd_date AS "workEndDate",
  17. a.name AS "name",
  18. a.gender AS "gender",
  19. a.nation AS "nation",
  20. a.id_card AS "idCard",
  21. a.age AS "age",
  22. a.birthday AS "birthday",
  23. a.calendar AS "calendar",
  24. a.email AS "email",
  25. a.mobile AS "mobile",
  26. a.phone AS "phone",
  27. a.marriage AS "marriage",
  28. a.politics AS "politics",
  29. a.ex_soldier AS "exSoldier",
  30. a.address AS "address",
  31. a.native_place AS "nativePlace.id",
  32. a.household AS "household",
  33. a.duty AS "duty",
  34. a.job_grade AS "jobGrade.id",
  35. a.status AS "status",
  36. a.entry_date AS "entryDate",
  37. a.work_date AS "workDate",
  38. a.bank_name AS "bankName",
  39. a.bank_card AS "bankCard",
  40. a.industry_date AS "industryDate",
  41. a.ts AS "ts",
  42. a.picture AS "picture",
  43. o.top_company AS "office.name",
  44. o.top_company AS "office.topCompany",
  45. a.user_id AS "userId",
  46. a.branch_office AS "branchOffice.id",
  47. branch.name AS "branchOffice.name",
  48. s.name AS "company.name",
  49. jg.name AS "jobGrade.name",
  50. jg.pay AS "salary",
  51. nativePlace.name AS "nativePlace.name",
  52. a.percent AS "percent",
  53. a.try_end_time AS "tryEndTime"
  54. </sql>
  55. <sql id="workStaffBasicInfoJoins">
  56. LEFT JOIN sys_office o ON o.id = a.office_id
  57. LEFT JOIN sys_office branch ON branch.id = a.branch_office
  58. LEFT JOIN sys_office s ON s.id = a.company_id
  59. LEFT JOIN sys_user u ON u.id = a.create_by
  60. LEFT JOIN sys_area nativePlace ON nativePlace.id = a.native_place
  61. LEFT JOIN work_job_grade jg ON jg.id = a.job_grade
  62. </sql>
  63. <select id="get" resultType="WorkStaffBasicInfo" >
  64. SELECT
  65. <include refid="workStaffBasicInfoColumns"/>
  66. FROM work_staff_achives a
  67. <include refid="workStaffBasicInfoJoins"/>
  68. WHERE a.id = #{id}
  69. </select>
  70. <select id="getByUserId" resultType="WorkStaffBasicInfo" >
  71. SELECT
  72. <include refid="workStaffBasicInfoColumns"/>
  73. FROM work_staff_achives a
  74. <include refid="workStaffBasicInfoJoins"/>
  75. WHERE a.user_id = #{id}
  76. </select>
  77. <select id="findList" resultType="WorkStaffBasicInfo" >
  78. SELECT
  79. <include refid="workStaffBasicInfoColumns"/>
  80. FROM work_staff_achives a
  81. <include refid="workStaffBasicInfoJoins"/>
  82. <where>
  83. a.del_flag = #{DEL_FLAG_NORMAL}
  84. <if test="company != null and company.id != null and company.id != ''">
  85. AND a.company_id = #{company.id}
  86. </if>
  87. <if test="office != null and office.id != null and office.id != ''">
  88. AND a.office_id = #{office.id}
  89. </if>
  90. <if test="no != null and no != ''">
  91. AND a.no = #{no}
  92. </if>
  93. <if test="name != null and name != ''">
  94. AND a.name LIKE
  95. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  96. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  97. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  98. </if>
  99. <if test="idCard != null and idCard != ''">
  100. AND a.id_card = #{idCard}
  101. </if>
  102. <if test="mobile != null and mobile != ''">
  103. AND a.mobile = #{mobile}
  104. </if>
  105. <if test="jobGrade != null and jobGrade.id !=null and jobGrade.id != ''">
  106. AND a.job_grade = #{jobGrade.id}
  107. </if>
  108. <if test="status != null and status != ''">
  109. AND a.status = #{status}
  110. </if>
  111. <if test="beginEntryDate != null">
  112. AND a.entry_date >= #{beginEntryDate}
  113. </if>
  114. <if test="endEntryDate != null">
  115. AND a.entry_date &lt;= #{endEntryDate}
  116. </if>
  117. <if test="minAge != null">
  118. AND a.age >= #{minAge}
  119. </if>
  120. <if test="maxAge != null">
  121. AND a.age &lt;= #{maxAge}
  122. </if>
  123. <if test="nation != null and nation !=''">
  124. AND a.nation = #{nation}
  125. </if>
  126. <if test="calendar != null and calendar !=''">
  127. AND a.calendar = #{calendar}
  128. </if>
  129. <if test="gender != null and gender !=''">
  130. AND a.gender = #{gender}
  131. </if>
  132. <if test="marriage != null and marriage !=''">
  133. AND a.marriage = #{marriage}
  134. </if>
  135. <if test="politics != null and politics !=''">
  136. AND a.politics = #{politics}
  137. </if>
  138. <if test="minSalary != null">
  139. AND jg.pay >= #{minSalary}
  140. </if>
  141. <if test="maxSalary != null">
  142. AND jg.pay &lt;= #{maxSalary}
  143. </if>
  144. <if test="beginWorkDate != null">
  145. AND a.work_date >= #{beginWorkDate}
  146. </if>
  147. <if test="endWorkDate != null">
  148. AND a.work_date &lt;= #{endWorkDate}
  149. </if>
  150. <if test="beginBirthdayDate != null">
  151. AND a.birthday >= #{beginBirthdayDate}
  152. </if>
  153. <if test="endBirthdayDate != null">
  154. AND a.birthday &lt;= #{endBirthdayDate}
  155. </if>
  156. <if test="minPercent != null and minPercent !=''">
  157. AND a.percent >= #{minPercent}
  158. </if>
  159. <if test="maxPercent != null and maxPercent!=''">
  160. AND a.percent &lt;= #{maxPercent}
  161. </if>
  162. <if test="sqlMap.dsf !=null and sqlMap.dsf !=''">
  163. AND ((a.user_id = #{currentUser.id} AND a.branch_office = #{currentUser.branchOffice.id})${sqlMap.dsf} )
  164. </if>
  165. </where>
  166. <choose>
  167. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  168. ORDER BY ${page.orderBy}
  169. </when>
  170. <otherwise>
  171. ORDER BY a.entry_date DESC
  172. </otherwise>
  173. </choose>
  174. </select>
  175. <select id="findListByRoleList" resultType="WorkStaffBasicInfo">
  176. select
  177. <include refid="workStaffBasicInfoColumns"/>
  178. FROM work_staff_achives a
  179. <include refid="workStaffBasicInfoJoins"/>
  180. LEFT JOIN sys_user_role ur ON ur.user_id = a.user_id
  181. LEFT JOIN sys_role r ON ur.role_id = r.id
  182. WHERE
  183. a.del_flag = #{DEL_FLAG_NORMAL} AND r.id = #{roleId} AND `status` IN ('试用','正式','劳务')
  184. <if test="company != null and company.id != null and company.id != ''">
  185. AND a.company_id = #{company.id}
  186. </if>
  187. <if test="office != null and office.id != null and office.id != ''">
  188. AND a.office_id = #{office.id}
  189. </if>
  190. <if test="no != null and no != ''">
  191. AND a.no = #{no}
  192. </if>
  193. <if test="name != null and name != ''">
  194. AND a.name LIKE
  195. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  196. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  197. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  198. </if>
  199. <if test="idCard != null and idCard != ''">
  200. AND a.id_card = #{idCard}
  201. </if>
  202. <if test="mobile != null and mobile != ''">
  203. AND a.mobile = #{mobile}
  204. </if>
  205. <if test="jobGrade != null and jobGrade.id !=null and jobGrade.id != ''">
  206. AND a.job_grade = #{jobGrade.id}
  207. </if>
  208. <if test="status != null and status != ''">
  209. AND a.status = #{status}
  210. </if>
  211. <if test="beginEntryDate != null">
  212. AND a.entry_date >= #{beginEntryDate}
  213. </if>
  214. <if test="endEntryDate != null">
  215. AND a.entry_date &lt;= #{endEntryDate}
  216. </if>
  217. <if test="achiveId != null and achiveId !=''">
  218. AND a.achive_id = #{achiveId}
  219. </if>
  220. <choose>
  221. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  222. ORDER BY ${page.orderBy}
  223. </when>
  224. <otherwise>
  225. ORDER BY a.update_date DESC
  226. </otherwise>
  227. </choose>
  228. </select>
  229. <select id="getByCompany" resultType="java.lang.Integer" >
  230. select count(*) FROM work_staff_achives
  231. where
  232. user_id = #{userId}
  233. AND company_id = #{company.id}
  234. AND `status` IN ('试用','正式','劳务')
  235. AND del_flag = '0'
  236. </select>
  237. <select id="getByBranchCompany" resultType="java.lang.Integer" >
  238. select count(*) FROM work_staff_achives
  239. where
  240. user_id = #{userId}
  241. AND branch_office = #{branchOffice.id}
  242. AND `status` IN ('试用','正式','劳务')
  243. AND del_flag = '0'
  244. </select>
  245. <select id="getByCompanyInfo" resultType="WorkStaffBasicInfo" >
  246. select
  247. <include refid="workStaffBasicInfoColumns"/>
  248. FROM work_staff_achives a
  249. <include refid="workStaffBasicInfoJoins"/>
  250. where
  251. a.user_id = #{userId}
  252. AND a.company_id = #{company.id}
  253. AND a.`status` IN ('试用','正式','劳务')
  254. AND a.del_flag = '0'
  255. </select>
  256. <select id="getAllListInfo" resultType="WorkStaffBasicInfo" >
  257. select
  258. <include refid="workStaffBasicInfoColumns"/>
  259. FROM work_staff_achives a
  260. <include refid="workStaffBasicInfoJoins"/>
  261. where
  262. a.`status` IN ('试用','正式','劳务')
  263. AND a.del_flag = '0'
  264. </select>
  265. <select id="getByUserOffice" resultType="WorkStaffBasicInfo" >
  266. select
  267. <include refid="workStaffBasicInfoColumns"/>
  268. FROM work_staff_achives a
  269. <include refid="workStaffBasicInfoJoins"/>
  270. where
  271. a.user_id = #{userId}
  272. AND a.office_id = #{office.id}
  273. AND a.`status` IN ('试用','正式','劳务')
  274. AND a.del_flag = '0'
  275. </select>
  276. <select id="getByOffice" resultType="WorkStaffBasicInfo" >
  277. select
  278. <include refid="workStaffBasicInfoColumns"/>
  279. FROM work_staff_achives a
  280. <include refid="workStaffBasicInfoJoins"/>
  281. where
  282. AND a.office_id = #{office.id}
  283. AND a.`status` IN ('试用','正式','劳务')
  284. AND a.del_flag = '0'
  285. </select>
  286. <select id="getByNoName" resultType="WorkStaffBasicInfo" >
  287. select
  288. <include refid="workStaffBasicInfoColumns"/>
  289. FROM work_staff_achives a
  290. <include refid="workStaffBasicInfoJoins"/>
  291. where
  292. a.no = #{no}
  293. AND a.name = #{name}
  294. AND a.company_id = #{company.id}
  295. AND a.`status` IN ('试用','正式','劳务')
  296. AND a.del_flag = '0'
  297. </select>
  298. <select id="findAllList" resultType="WorkStaffBasicInfo" >
  299. SELECT
  300. <include refid="workStaffBasicInfoColumns"/>
  301. FROM work_staff_achives a
  302. <include refid="workStaffBasicInfoJoins"/>
  303. <where>
  304. a.del_flag = #{DEL_FLAG_NORMAL}
  305. </where>
  306. <choose>
  307. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  308. ORDER BY ${page.orderBy}
  309. </when>
  310. <otherwise>
  311. ORDER BY a.update_date DESC
  312. </otherwise>
  313. </choose>
  314. </select>
  315. <select id="findInfoList" resultType="WorkStaffBasicInfo" >
  316. SELECT
  317. <include refid="workStaffBasicInfoColumns"/>
  318. FROM work_staff_achives a
  319. <include refid="workStaffBasicInfoJoins"/>
  320. <where>
  321. a.del_flag = '0'
  322. AND a.`status` IN ('试用','正式','劳务')
  323. </where>
  324. </select>
  325. <insert id="insert">
  326. INSERT INTO work_staff_achives(
  327. id,
  328. create_by,
  329. create_date,
  330. update_by,
  331. update_date,
  332. remarks,
  333. del_flag,
  334. office_id,
  335. company_id,
  336. no,
  337. name,
  338. dimission_date,
  339. workEnd_date,
  340. gender,
  341. nation,
  342. id_card,
  343. age,
  344. birthday,
  345. calendar,
  346. email,
  347. mobile,
  348. marriage,
  349. politics,
  350. ex_soldier,
  351. address,
  352. native_place,
  353. household,
  354. duty,
  355. job_grade,
  356. status,
  357. entry_date,
  358. work_date,
  359. bank_name,
  360. bank_card,
  361. industry_date,
  362. ts,
  363. picture,
  364. user_id,
  365. branch_office,
  366. percent,
  367. try_end_time
  368. ) VALUES (
  369. #{id},
  370. #{createBy.id},
  371. #{createDate},
  372. #{updateBy.id},
  373. #{updateDate},
  374. #{remarks},
  375. #{delFlag},
  376. #{office.id},
  377. #{company.id},
  378. #{no},
  379. #{name},
  380. #{dimissionDate},
  381. #{workEndDate},
  382. #{gender},
  383. #{nation},
  384. #{idCard},
  385. #{age},
  386. #{birthday},
  387. #{calendar},
  388. #{email},
  389. #{mobile},
  390. #{marriage},
  391. #{politics},
  392. #{exSoldier},
  393. #{address},
  394. #{nativePlace.id},
  395. #{household},
  396. #{duty},
  397. #{jobGrade.id},
  398. #{status},
  399. #{entryDate},
  400. #{workDate},
  401. #{bankName},
  402. #{bankCard},
  403. #{industryDate},
  404. #{ts},
  405. #{picture},
  406. #{userId},
  407. #{branchOffice.id},
  408. #{percent},
  409. #{tryEndTime}
  410. )
  411. </insert>
  412. <update id="update">
  413. UPDATE work_staff_achives SET
  414. update_by = #{updateBy.id},
  415. update_date = #{updateDate},
  416. remarks = #{remarks},
  417. office_id = #{office.id},
  418. company_id = #{company.id},
  419. no = #{no},
  420. name = #{name},
  421. dimission_date= #{dimissionDate},
  422. workEnd_date = #{workEndDate},
  423. gender = #{gender},
  424. nation = #{nation},
  425. id_card = #{idCard},
  426. age = #{age},
  427. birthday = #{birthday},
  428. calendar = #{calendar},
  429. email = #{email},
  430. mobile = #{mobile},
  431. marriage = #{marriage},
  432. politics = #{politics},
  433. ex_soldier = #{exSoldier},
  434. address = #{address},
  435. native_place = #{nativePlace.id},
  436. household = #{household},
  437. duty = #{duty},
  438. job_grade = #{jobGrade.id},
  439. status = #{status},
  440. entry_date = #{entryDate},
  441. work_date = #{workDate},
  442. bank_name = #{bankName},
  443. bank_card = #{bankCard},
  444. industry_date = #{industryDate},
  445. ts = #{ts},
  446. picture = #{picture},
  447. user_id = #{userId},
  448. branch_office = #{branchOffice.id},
  449. percent = #{percent},
  450. try_end_time = #{tryEndTime}
  451. WHERE id = #{id}
  452. </update>
  453. <!--物理删除-->
  454. <update id="delete">
  455. DELETE FROM work_staff_achives
  456. WHERE id = #{id}
  457. </update>
  458. <!--逻辑删除-->
  459. <update id="deleteByLogic">
  460. UPDATE work_staff_achives SET
  461. del_flag = #{DEL_FLAG_DELETE}
  462. WHERE id = #{id}
  463. </update>
  464. <!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
  465. <select id="findUniqueByProperty" resultType="WorkStaffBasicInfo" statementType="STATEMENT">
  466. select * FROM work_staff_achives where ${propertyName} = '${value}'
  467. </select>
  468. <!--根据userId获取入职信息-->
  469. <select id="getWorkStaffBasicInfo" resultType="WorkStaffBasicInfo" parameterType="java.lang.String">
  470. select a.* ,
  471. o.top_company as "office.name",
  472. o.id as "office.id",
  473. jg.name AS "jobGrade.name",
  474. jg.id AS "jobGrade.id",
  475. jg.pay AS "salary",
  476. DATE_FORMAT(a.entry_date, '%Y-%m-%d') as entry_date,
  477. (select DATE_FORMAT(MAX(r.try_end_time), '%Y-%m-%d') from work_relationship r where r.staff_info_id=#{id}) tryEndTime
  478. FROM work_staff_achives a
  479. LEFT JOIN sys_office o on o.id=a.office_id
  480. LEFT JOIN work_job_grade jg ON jg.id = a.job_grade
  481. where a.id=#{id}
  482. </select>
  483. <select id="queryMaxNoWithCompany" resultType="String">
  484. SELECT max(SUBSTR(no,2)+0) FROM work_staff_achives where branch_office=#{branchOffice.id} and del_flag='0'
  485. </select>
  486. <select id="findUserList" resultType="WorkStaffBasicInfo" >
  487. SELECT
  488. <include refid="workStaffBasicInfoColumns"/>
  489. FROM work_staff_achives a
  490. <include refid="workStaffBasicInfoJoins"/>
  491. <where>
  492. a.del_flag = #{DEL_FLAG_NORMAL}
  493. <if test="name != null and name != ''">
  494. AND a.name LIKE
  495. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  496. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  497. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  498. </if>
  499. <if test="office != null and office.id != null and office.id !=''">
  500. AND a.office_id= #{office.id}
  501. </if>
  502. <if test="no != null and no != ''">
  503. AND a.no = #{no}
  504. </if>
  505. <if test="userId != null and userId != ''">
  506. AND a.user_id = #{userId}
  507. </if>
  508. <if test="gender != null and gender != ''">
  509. AND a.gender = #{gender}
  510. </if>
  511. <if test="jobGrade != null and jobGrade.id != null and jobGrade.id !=''">
  512. AND a.job_grade = #{jobGrade.id}
  513. </if>
  514. <if test="status != null and status != ''">
  515. AND a.status = #{status}
  516. </if>
  517. <if test="branchOffice != null and branchOffice.id != null and branchOffice.id != ''">
  518. AND a.branch_office = #{branchOffice.id}
  519. </if>
  520. <if test="sqlStr != null and sqlStr != ''">
  521. ${sqlStr}
  522. </if>
  523. </where>
  524. </select>
  525. <select id="findUserApplyList" resultType="WorkStaffBasicInfo" >
  526. SELECT
  527. <include refid="workStaffBasicInfoColumns"/>
  528. FROM work_staff_achives a
  529. <include refid="workStaffBasicInfoJoins"/>
  530. <where>
  531. a.del_flag = #{DEL_FLAG_NORMAL}
  532. <if test="name != null and name != ''">
  533. AND a.name LIKE
  534. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  535. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  536. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  537. </if>
  538. <if test="office != null and office.id != null and office.id !=''">
  539. AND a.office_id= #{office.id}
  540. </if>
  541. <if test="no != null and no != ''">
  542. AND a.no = #{no}
  543. </if>
  544. <if test="userId != null and userId != ''">
  545. AND a.user_id = #{userId}
  546. </if>
  547. <if test="gender != null and gender != ''">
  548. AND a.gender = #{gender}
  549. </if>
  550. <if test="jobGrade != null and jobGrade.id != null and jobGrade.id !=''">
  551. AND a.job_grade = #{jobGrade.id}
  552. </if>
  553. <if test="status != null and status != ''">
  554. AND a.status = #{status}
  555. </if>
  556. <if test="branchOffice != null and branchOffice.id != null and branchOffice.id != ''">
  557. AND a.branch_office = #{branchOffice.id}
  558. </if>
  559. and a.id not in (select r.basic_info_id from work_regular_apply r where r.state !='5' and r.del_flag !='1')
  560. </where>
  561. </select>
  562. <select id="findUserShipList" resultType="WorkStaffBasicInfo" >
  563. SELECT
  564. <include refid="workStaffBasicInfoColumns"/>
  565. FROM work_staff_achives a
  566. <include refid="workStaffBasicInfoJoins"/>
  567. <where>
  568. a.del_flag = #{DEL_FLAG_NORMAL}
  569. <if test="name != null and name != ''">
  570. AND a.name LIKE
  571. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  572. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  573. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  574. </if>
  575. <if test="office != null and office.id != null and office.id !=''">
  576. AND a.office_id= #{office.id}
  577. </if>
  578. <if test="no != null and no != ''">
  579. AND a.no = #{no}
  580. </if>
  581. <if test="userId != null and userId != ''">
  582. AND a.user_id = #{userId}
  583. </if>
  584. <if test="gender != null and gender != ''">
  585. AND a.gender = #{gender}
  586. </if>
  587. <if test="jobGrade != null and jobGrade.id != null and jobGrade.id !=''">
  588. AND a.job_grade = #{jobGrade.id}
  589. </if>
  590. <if test="status != null and status != ''">
  591. AND a.status = #{status}
  592. </if>
  593. <if test="branchOffice != null and branchOffice.id != null and branchOffice.id != ''">
  594. AND a.branch_office = #{branchOffice.id}
  595. </if>
  596. and a.id not in (select r.staff_info_id from work_relationship r where r.status !='5' and r.del_flag !='1')
  597. AND a.status in ('正式','试用','劳务')
  598. </where>
  599. </select>
  600. <select id="findListByIdCard" resultType="WorkStaffBasicInfo">
  601. SELECT
  602. a.*
  603. FROM work_staff_achives a
  604. <where>
  605. a.del_flag = #{DEL_FLAG_NORMAL}
  606. <if test="company != null and company.id != null and company.id != ''">
  607. AND a.company_id = #{company.id}
  608. </if>
  609. <if test="idCard != null and idCard != ''">
  610. AND a.id_card = #{idCard}
  611. </if>
  612. </where>
  613. ORDER BY a.entry_date DESC
  614. </select>
  615. <update id="updatePercent">
  616. UPDATE work_staff_achives SET percent=#{percent} WHERE id=#{id}
  617. </update>
  618. <select id="findTaskUserList" resultType="WorkStaffBasicInfo" >
  619. SELECT * FROM
  620. work_staff_achives a
  621. WHERE
  622. a.del_flag=0
  623. and a.`status` = '试用'
  624. and date_add(DATE_FORMAT(now(), '%Y-%m-%d'), interval #{day} day)=DATE_FORMAT(a.try_end_time, '%Y-%m-%d')
  625. AND a.id NOT IN (SELECT r.basic_info_id FROM work_regular_apply r WHERE r.del_flag = '0')
  626. and a.branch_office=#{branchOffice}
  627. </select>
  628. <select id="findUserInfoExcel" resultType="WorkStaffBasicInfo" >
  629. SELECT
  630. <include refid="workStaffBasicInfoColumns"/>
  631. FROM work_staff_achives a
  632. <include refid="workStaffBasicInfoJoins"/>
  633. WHERE a.name=#{name}
  634. and a.no=#{no}
  635. </select>
  636. <select id="findTemplateUser" resultType="WorkStaffBasicInfo" >
  637. select
  638. u.id as "userId",
  639. u.name as "name",
  640. a.no,
  641. a.gender,
  642. o.name as "office.name",
  643. o.top_company as "office.topCompany",
  644. jg.name as "jobGrade.name"
  645. from sys_user u
  646. left join work_staff_achives a on u.id=a.user_id
  647. left join sys_office o on o.id=u.office_id
  648. LEFT JOIN work_job_grade jg ON jg.id = a.job_grade
  649. <where>
  650. u.del_flag = #{DEL_FLAG_NORMAL}
  651. <if test="name != null and name != ''">
  652. AND u.name LIKE
  653. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  654. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  655. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  656. </if>
  657. <if test="office != null and office.id != null and office.id !=''">
  658. AND u.office_id= #{office.id}
  659. </if>
  660. <if test="no != null and no != ''">
  661. AND a.no = #{no}
  662. </if>
  663. <if test="gender != null and gender != ''">
  664. AND a.gender = #{gender}
  665. </if>
  666. <if test="jobGrade != null and jobGrade.id != null and jobGrade.id !=''">
  667. AND a.job_grade = #{jobGrade.id}
  668. </if>
  669. <if test="status != null and status != ''">
  670. AND a.status = #{status}
  671. </if>
  672. <choose>
  673. <when test="branchOffice != null and branchOffice.id != null and branchOffice.id != ''">
  674. and u.office_id in (select off.id from sys_office off where off.branch_office=#{branchOffice.id})
  675. </when>
  676. <otherwise>
  677. and u.office_id in
  678. (select off.id from sys_office off where off.parent_ids like concat('%',#{company.id},'%') and off.type=2 and (off.branch_office is null or off.branch_office=''))
  679. </otherwise>
  680. </choose>
  681. </where>
  682. </select>
  683. <select id="sysWarningUser" resultType="WorkStaffBasicInfo" >
  684. select
  685. u.id as "userId",
  686. u.name as "name",
  687. a.no,
  688. a.gender,
  689. o.name as "office.name",
  690. o.top_company as "office.topCompany",
  691. jg.name as "jobGrade.name"
  692. from sys_user u
  693. left join work_staff_achives a on u.id=a.user_id
  694. left join sys_office o on o.id=u.office_id
  695. LEFT JOIN work_job_grade jg ON jg.id = a.job_grade
  696. <where>
  697. u.del_flag = #{DEL_FLAG_NORMAL}
  698. <if test="name != null and name != ''">
  699. AND u.name LIKE
  700. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  701. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  702. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  703. </if>
  704. <if test="office != null and office.id != null and office.id !=''">
  705. AND u.office_id= #{office.id}
  706. </if>
  707. <if test="no != null and no != ''">
  708. AND a.no = #{no}
  709. </if>
  710. <if test="gender != null and gender != ''">
  711. AND a.gender = #{gender}
  712. </if>
  713. <if test="jobGrade != null and jobGrade.id != null and jobGrade.id !=''">
  714. AND a.job_grade = #{jobGrade.id}
  715. </if>
  716. <if test="status != null and status != ''">
  717. AND a.status = #{status}
  718. </if>
  719. and u.company_id=#{company.id}
  720. </where>
  721. </select>
  722. <select id="countByNo" resultType="int">
  723. SELECT count(*) from work_staff_achives a WHERE a.no = #{no} and a.company_id = #{company.id} and del_flag = '0'
  724. </select>
  725. <select id="findTaskBranchList" resultType="WorkStaffBasicInfo" >
  726. SELECT
  727. <include refid="workStaffBasicInfoColumns"/>
  728. FROM
  729. work_staff_achives a
  730. <include refid="workStaffBasicInfoJoins"/>
  731. WHERE
  732. a.del_flag=0
  733. and a.status = #{status}
  734. and a.branch_office is not null
  735. AND a.id NOT IN (SELECT r.basic_info_id FROM work_regular_apply r WHERE r.del_flag = '0')
  736. group by a.branch_office
  737. </select>
  738. <!--当前登录人获取档案-->
  739. <select id="getBasicInfo" resultType="WorkStaffBasicInfo" >
  740. SELECT
  741. <include refid="workStaffBasicInfoColumns"/>
  742. FROM work_staff_achives a
  743. <include refid="workStaffBasicInfoJoins"/>
  744. WHERE a.user_id = #{userId} and a.company_id=#{company.id} and a.status not in ('离职','退休')
  745. </select>
  746. <select id="getJob" resultType="WorkStaffBasicInfo" >
  747. SELECT
  748. <include refid="workStaffBasicInfoColumns"/>
  749. FROM work_staff_achives a
  750. <include refid="workStaffBasicInfoJoins"/>
  751. WHERE a.user_id = #{userId} limit 1
  752. </select>
  753. <update id="updateStatus">
  754. update work_staff_achives set
  755. status = #{status}
  756. where user_id = #{id}
  757. </update>
  758. <!-- 我的信息-修改用户的四个属性,同步到user,achieves,basicInfo-->
  759. <update id="updateWorkStaffAchieves" parameterType="WorkStaffBasicInfo">
  760. update work_staff_achives
  761. <set>
  762. <if test="name != null and name != ''">
  763. name = #{name},
  764. </if>
  765. <if test="email != null and email != ''">
  766. email = #{email},
  767. </if>
  768. <if test="phone != null and phone != ''">
  769. phone = #{phone},
  770. </if>
  771. <if test="remarks != null and remarks != ''">
  772. remarks = #{remarks}
  773. </if>
  774. </set>
  775. where user_id = #{userId}
  776. </update>
  777. </mapper>