WorkStaffBasicInfoDao.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  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.WorkStaffBasicInfoDao">
  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.name AS "name",
  16. a.gender AS "gender",
  17. a.nation AS "nation",
  18. a.id_card AS "idCard",
  19. a.age AS "age",
  20. a.birthday AS "birthday",
  21. a.calendar AS "calendar",
  22. a.email AS "email",
  23. a.mobile AS "mobile",
  24. a.marriage AS "marriage",
  25. a.politics AS "politics",
  26. a.ex_soldier AS "exSoldier",
  27. a.address AS "address",
  28. a.native_place AS "nativePlace.id",
  29. a.household AS "household",
  30. a.duty AS "duty",
  31. a.job_grade AS "jobGrade.id",
  32. a.status AS "status",
  33. a.entry_date AS "entryDate",
  34. a.work_date AS "workDate",
  35. a.bank_name AS "bankName",
  36. a.bank_card AS "bankCard",
  37. a.industry_date AS "industryDate",
  38. a.ts AS "ts",
  39. a.picture AS "picture",
  40. o.top_company AS "office.name",
  41. a.user_id AS "userId",
  42. a.branch_office AS "branchOffice.id",
  43. branch.name AS "branchOffice.name",
  44. s.name AS "company.name",
  45. jg.name AS "jobGrade.name",
  46. jg.pay AS "salary",
  47. a.achive_id AS "achiveId",
  48. nativePlace.name AS "nativePlace.name",
  49. a.try_end_time AS "tryEndTime"
  50. -- ur.role_id AS "roleId",
  51. -- r.name AS "roleName"
  52. </sql>
  53. <sql id="workStaffBasicInfoJoins">
  54. LEFT JOIN sys_office o ON o.id = a.office_id
  55. LEFT JOIN sys_office branch ON branch.id = a.branch_office
  56. LEFT JOIN sys_office s ON s.id = a.company_id
  57. LEFT JOIN sys_user u ON u.id = a.create_by
  58. LEFT JOIN sys_area nativePlace ON nativePlace.id = a.native_place
  59. LEFT JOIN work_job_grade jg ON jg.id = a.job_grade
  60. -- LEFT JOIN sys_user_role ur ON a.user_id = ur.user_id
  61. -- LEFT JOIN sys_role r ON ur.role_id = r.id
  62. </sql>
  63. <select id="get" resultType="WorkStaffBasicInfo" >
  64. SELECT
  65. <include refid="workStaffBasicInfoColumns"/>
  66. FROM work_staff_basic_info a
  67. <include refid="workStaffBasicInfoJoins"/>
  68. WHERE a.id = #{id}
  69. </select>
  70. <select id="getByCompany" resultType="java.lang.Integer" >
  71. select count(*) FROM work_staff_basic_info
  72. where
  73. user_id = #{userId}
  74. AND company_id = #{company.id}
  75. AND `status` IN ('试用','正式','劳务')
  76. AND del_flag = '0'
  77. </select>
  78. <select id="getByCompanyInfo" resultType="WorkStaffBasicInfo" >
  79. select
  80. <include refid="workStaffBasicInfoColumns"/>
  81. FROM work_staff_basic_info
  82. <include refid="workStaffBasicInfoJoins"/>
  83. where
  84. a.user_id = #{userId}
  85. AND a.company_id = #{company.id}
  86. AND a.`status` IN ('试用','正式','劳务')
  87. AND a.del_flag = '0'
  88. </select>
  89. <select id="findListByRoleList" resultType="WorkStaffBasicInfo">
  90. select
  91. <include refid="workStaffBasicInfoColumns"/>
  92. FROM work_staff_basic_info a
  93. <include refid="workStaffBasicInfoJoins"/>
  94. LEFT JOIN sys_user_role ur ON ur.user_id = a.user_id
  95. LEFT JOIN sys_role r ON ur.role_id = r.id
  96. WHERE
  97. a.del_flag = #{DEL_FLAG_NORMAL} AND r.id = #{roleId}
  98. <if test="company != null and company.id != null and company.id != ''">
  99. AND a.company_id = #{company.id}
  100. </if>
  101. <if test="office != null and office.id != null and office.id != ''">
  102. AND a.office_id = #{office.id}
  103. </if>
  104. <if test="no != null and no != ''">
  105. AND a.no = #{no}
  106. </if>
  107. <if test="name != null and name != ''">
  108. AND a.name LIKE
  109. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  110. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  111. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  112. </if>
  113. <if test="idCard != null and idCard != ''">
  114. AND a.id_card = #{idCard}
  115. </if>
  116. <if test="mobile != null and mobile != ''">
  117. AND a.mobile = #{mobile}
  118. </if>
  119. <if test="jobGrade != null and jobGrade.id !=null and jobGrade.id != ''">
  120. AND a.job_grade = #{jobGrade.id}
  121. </if>
  122. <if test="status != null and status != ''">
  123. AND a.status = #{status}
  124. </if>
  125. <if test="beginEntryDate != null">
  126. AND a.entry_date >= #{beginEntryDate}
  127. </if>
  128. <if test="endEntryDate != null">
  129. AND a.entry_date &lt;= #{endEntryDate}
  130. </if>
  131. <if test="achiveId != null and achiveId !=''">
  132. AND a.achive_id = #{achiveId}
  133. </if>
  134. <choose>
  135. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  136. ORDER BY ${page.orderBy}
  137. </when>
  138. <otherwise>
  139. ORDER BY a.update_date DESC
  140. </otherwise>
  141. </choose>
  142. </select>
  143. <select id="findList" resultType="WorkStaffBasicInfo" >
  144. SELECT
  145. <include refid="workStaffBasicInfoColumns"/>
  146. FROM work_staff_basic_info a
  147. <include refid="workStaffBasicInfoJoins"/>
  148. <where>
  149. a.del_flag = #{DEL_FLAG_NORMAL}
  150. <if test="company != null and company.id != null and company.id != ''">
  151. AND a.company_id = #{company.id}
  152. </if>
  153. <if test="office != null and office.id != null and office.id != ''">
  154. AND a.office_id = #{office.id}
  155. </if>
  156. <if test="no != null and no != ''">
  157. AND a.no = #{no}
  158. </if>
  159. <if test="name != null and name != ''">
  160. AND a.name LIKE
  161. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  162. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  163. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  164. </if>
  165. <if test="idCard != null and idCard != ''">
  166. AND a.id_card = #{idCard}
  167. </if>
  168. <if test="mobile != null and mobile != ''">
  169. AND a.mobile = #{mobile}
  170. </if>
  171. <if test="jobGrade != null and jobGrade.id !=null and jobGrade.id != ''">
  172. AND a.job_grade = #{jobGrade.id}
  173. </if>
  174. <if test="status != null and status != ''">
  175. AND a.status = #{status}
  176. </if>
  177. <if test="beginEntryDate != null">
  178. AND a.entry_date >= #{beginEntryDate}
  179. </if>
  180. <if test="endEntryDate != null">
  181. AND a.entry_date &lt;= #{endEntryDate}
  182. </if>
  183. <if test="achiveId != null and achiveId !=''">
  184. AND a.achive_id = #{achiveId}
  185. </if>
  186. <if test="sqlMap.dsf !=null and sqlMap.dsf !=''">
  187. AND ((a.user_id = #{currentUser.id} AND a.branch_office = #{currentUser.branchOffice.id})${sqlMap.dsf} )
  188. </if>
  189. </where>
  190. <choose>
  191. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  192. ORDER BY ${page.orderBy}
  193. </when>
  194. <otherwise>
  195. ORDER BY a.entry_date DESC
  196. </otherwise>
  197. </choose>
  198. </select>
  199. <select id="findAllList" resultType="WorkStaffBasicInfo" >
  200. SELECT
  201. <include refid="workStaffBasicInfoColumns"/>
  202. FROM work_staff_basic_info a
  203. <include refid="workStaffBasicInfoJoins"/>
  204. <where>
  205. a.del_flag = #{DEL_FLAG_NORMAL}
  206. </where>
  207. <choose>
  208. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  209. ORDER BY ${page.orderBy}
  210. </when>
  211. <otherwise>
  212. ORDER BY a.update_date DESC
  213. </otherwise>
  214. </choose>
  215. </select>
  216. <insert id="insert">
  217. INSERT INTO work_staff_basic_info(
  218. id,
  219. create_by,
  220. create_date,
  221. update_by,
  222. update_date,
  223. remarks,
  224. del_flag,
  225. office_id,
  226. company_id,
  227. no,
  228. name,
  229. gender,
  230. nation,
  231. id_card,
  232. age,
  233. birthday,
  234. calendar,
  235. email,
  236. mobile,
  237. marriage,
  238. politics,
  239. ex_soldier,
  240. address,
  241. native_place,
  242. household,
  243. duty,
  244. job_grade,
  245. status,
  246. entry_date,
  247. work_date,
  248. bank_name,
  249. bank_card,
  250. industry_date,
  251. ts,
  252. picture,
  253. user_id,
  254. branch_office,
  255. achive_id,
  256. try_end_time
  257. ) VALUES (
  258. #{id},
  259. #{createBy.id},
  260. #{createDate},
  261. #{updateBy.id},
  262. #{updateDate},
  263. #{remarks},
  264. #{delFlag},
  265. #{office.id},
  266. #{company.id},
  267. #{no},
  268. #{name},
  269. #{gender},
  270. #{nation},
  271. #{idCard},
  272. #{age},
  273. #{birthday},
  274. #{calendar},
  275. #{email},
  276. #{mobile},
  277. #{marriage},
  278. #{politics},
  279. #{exSoldier},
  280. #{address},
  281. #{nativePlace.id},
  282. #{household},
  283. #{duty},
  284. #{jobGrade.id},
  285. #{status},
  286. #{entryDate},
  287. #{workDate},
  288. #{bankName},
  289. #{bankCard},
  290. #{industryDate},
  291. #{ts},
  292. #{picture},
  293. #{userId},
  294. #{branchOffice.id},
  295. #{achiveId},
  296. #{tryEndTime}
  297. )
  298. </insert>
  299. <update id="update">
  300. UPDATE work_staff_basic_info SET
  301. update_by = #{updateBy.id},
  302. update_date = #{updateDate},
  303. remarks = #{remarks},
  304. office_id = #{office.id},
  305. company_id = #{company.id},
  306. no = #{no},
  307. name = #{name},
  308. gender = #{gender},
  309. nation = #{nation},
  310. id_card = #{idCard},
  311. age = #{age},
  312. birthday = #{birthday},
  313. calendar = #{calendar},
  314. email = #{email},
  315. mobile = #{mobile},
  316. marriage = #{marriage},
  317. politics = #{politics},
  318. ex_soldier = #{exSoldier},
  319. address = #{address},
  320. native_place = #{nativePlace.id},
  321. household = #{household},
  322. duty = #{duty},
  323. job_grade = #{jobGrade.id},
  324. status = #{status},
  325. entry_date = #{entryDate},
  326. work_date = #{workDate},
  327. bank_name = #{bankName},
  328. bank_card = #{bankCard},
  329. industry_date = #{industryDate},
  330. ts = #{ts},
  331. picture = #{picture},
  332. user_id = #{userId},
  333. branch_office = #{branchOffice.id},
  334. achive_id = #{achiveId},
  335. try_end_time = #{tryEndTime}
  336. WHERE id = #{id}
  337. </update>
  338. <!--物理删除-->
  339. <update id="delete">
  340. DELETE FROM work_staff_basic_info
  341. WHERE id = #{id}
  342. </update>
  343. <!--逻辑删除-->
  344. <update id="deleteByLogic">
  345. UPDATE work_staff_basic_info SET
  346. del_flag = #{DEL_FLAG_DELETE}
  347. WHERE id = #{id}
  348. </update>
  349. <!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
  350. <select id="findUniqueByProperty" resultType="WorkStaffBasicInfo" statementType="STATEMENT">
  351. select * FROM work_staff_basic_info where ${propertyName} = '${value}'
  352. </select>
  353. <!--根据userId获取入职信息-->
  354. <select id="getWorkStaffBasicInfo" resultType="WorkStaffBasicInfo" parameterType="java.lang.String">
  355. select a.* ,
  356. o.name as "office.name",
  357. jg.name AS "jobGrade.name",
  358. jg.pay AS "salary"
  359. FROM work_staff_basic_info a
  360. LEFT JOIN sys_office o on o.id=a.office_id
  361. LEFT JOIN work_job_grade jg ON jg.id = a.job_grade
  362. where a.id=#{id}
  363. </select>
  364. <!-- 根据userId,获取workStaffBasicInfo信息-->
  365. <select id="getWorkStaffBasicInfoByUserId" resultType="WorkStaffBasicInfo" parameterType="java.lang.String">
  366. select a.* ,
  367. o.name as "office.name",
  368. jg.name AS "jobGrade.name",
  369. jg.id AS "jobGrade.id",
  370. jg.pay AS "salary"
  371. FROM work_staff_basic_info a
  372. LEFT JOIN sys_office o on o.id=a.office_id
  373. LEFT JOIN work_job_grade jg ON jg.id = a.job_grade
  374. where a.user_id=#{userId,jdbcType=VARCHAR}
  375. and a.status = "试用"
  376. </select>
  377. <select id="queryMaxNoWithCompany" resultType="String">
  378. SELECT max(SUBSTR(no,5)+0) FROM work_staff_achives where branch_office=#{branchOffice.id} and del_flag='0'
  379. </select>
  380. <select id="findUserList" resultType="WorkStaffBasicInfo" >
  381. SELECT
  382. <include refid="workStaffBasicInfoColumns"/>
  383. FROM work_staff_basic_info a
  384. <include refid="workStaffBasicInfoJoins"/>
  385. /*left join work_relationship wrp on a.id = wrp.staff_info_id*/
  386. <where>
  387. a.del_flag = #{DEL_FLAG_NORMAL}
  388. <if test="name != null and name != ''">
  389. AND a.name LIKE
  390. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  391. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  392. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  393. </if>
  394. <if test="office != null and office.id != null and office.id !=''">
  395. AND a.office_id= #{office.id}
  396. </if>
  397. <if test="no != null and no != ''">
  398. AND a.no = #{no}
  399. </if>
  400. <!--<if test="relationshipStatus != null and relationshipStatus != ''">
  401. AND (wrp.del_flag ='0' or wrp.del_flag is null) AND (wrp.status = #{relationshipStatus} or wrp.status is null)
  402. </if>-->
  403. <if test="gender != null and gender != ''">
  404. AND a.gender = #{gender}
  405. </if>
  406. <if test="jobGrade != null and jobGrade != ''">
  407. AND a.job_grade = #{jobGrade}
  408. </if>
  409. <if test="status != null and status != ''">
  410. AND a.status = #{status}
  411. </if>
  412. and a.office_id in (${sqlStr})
  413. </where>
  414. </select>
  415. <select id="findListByIdCard" resultType="WorkStaffBasicInfo">
  416. SELECT
  417. a.*
  418. FROM work_staff_basic_info a
  419. <where>
  420. a.del_flag = #{DEL_FLAG_NORMAL}
  421. <if test="company != null and company.id != null and company.id != ''">
  422. AND a.company_id = #{company.id}
  423. </if>
  424. <if test="idCard != null and idCard != ''">
  425. AND a.id_card = #{idCard}
  426. </if>
  427. </where>
  428. </select>
  429. <select id="findListByAchiveId" resultType="WorkStaffBasicInfo">
  430. SELECT
  431. a.*
  432. FROM work_staff_basic_info a
  433. <where>
  434. a.del_flag = #{DEL_FLAG_NORMAL}
  435. <if test="achiveId != null and achiveId != ''">
  436. AND a.achive_id = #{achiveId}
  437. </if>
  438. <if test="branchOffice != null and branchOffice.id != null and branchOffice.id != ''">
  439. AND a.branch_office = #{branchOffice.id}
  440. </if>
  441. </where>
  442. </select>
  443. <select id="findListByUserId" resultType="WorkStaffBasicInfo">
  444. SELECT
  445. a.*
  446. FROM work_staff_basic_info a
  447. <where>
  448. a.del_flag = #{DEL_FLAG_NORMAL}
  449. <if test="achiveId != null and achiveId != ''">
  450. AND a.user_id = #{userId}
  451. </if>
  452. <if test="branchOffice != null and branchOffice.id != null and branchOffice.id != ''">
  453. AND a.branch_office = #{branchOffice.id}
  454. </if>
  455. </where>
  456. </select>
  457. <update id="updateStatus">
  458. update work_staff_basic_info set
  459. status = #{status}
  460. where user_id = #{id}
  461. </update>
  462. </mapper>