DepartmentMapper.xml 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  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.goafanti.common.dao.DepartmentMapper">
  4. <resultMap id="BaseResultMap" type="com.goafanti.common.model.Department">
  5. <id column="id" jdbcType="VARCHAR" property="id" />
  6. <result column="create_id" jdbcType="VARCHAR" property="createId" />
  7. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  8. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
  9. <result column="deleted_sign" jdbcType="INTEGER" property="deletedSign" />
  10. <result column="name" jdbcType="VARCHAR" property="name" />
  11. <result column="type" jdbcType="VARCHAR" property="type" />
  12. <result column="manager_id" jdbcType="VARCHAR" property="managerId" />
  13. <result column="dep_no" jdbcType="VARCHAR" property="depNo" />
  14. <result column="super_id" jdbcType="VARCHAR" property="superId" />
  15. <result column="remarks" jdbcType="VARCHAR" property="remarks" />
  16. <result column="status" jdbcType="VARCHAR" property="status" />
  17. <result column="abbreviation" jdbcType="VARCHAR" property="abbreviation" />
  18. <result column="finance_id" jdbcType="VARCHAR" property="financeId" />
  19. <result column="province" jdbcType="INTEGER" property="province" />
  20. <result column="working_hours_type" jdbcType="INTEGER" property="workingHoursType" />
  21. <result column="hide_sign" jdbcType="INTEGER" property="hideSign" />
  22. <result column="lvl" jdbcType="INTEGER" property="lvl" />
  23. <result column="current_amount" jdbcType="DECIMAL" property="currentAmount" />
  24. <result column="subordinate_amount" jdbcType="DECIMAL" property="subordinateAmount" />
  25. <result column="total_amount" jdbcType="DECIMAL" property="totalAmount" />
  26. <result column="retrial_finance_id" jdbcType="VARCHAR" property="retrialFinanceId" />
  27. <result column="approval" jdbcType="INTEGER" property="approval" />
  28. <result column="approval_aid" jdbcType="VARCHAR" property="approvalAid" />
  29. <result column="expense_finance_id" jdbcType="VARCHAR" property="expenseFinanceId" />
  30. <result column="expense_retrial_finance_id" jdbcType="VARCHAR" property="expenseRetrialFinanceId" />
  31. </resultMap>
  32. <sql id="Base_Column_List">
  33. id, create_id, create_time, update_time, deleted_sign, `name`, `type`, manager_id,
  34. dep_no, super_id, remarks, `status`, abbreviation, finance_id, province, working_hours_type,
  35. hide_sign, lvl, current_amount, subordinate_amount, total_amount, retrial_finance_id,
  36. approval, approval_aid, expense_finance_id, expense_retrial_finance_id
  37. </sql>
  38. <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
  39. select
  40. <include refid="Base_Column_List" />
  41. from department
  42. where id = #{id,jdbcType=VARCHAR}
  43. </select>
  44. <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
  45. delete from department
  46. where id = #{id,jdbcType=VARCHAR}
  47. </delete>
  48. <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.Department" useGeneratedKeys="true">
  49. insert into department (create_id, create_time, update_time,
  50. deleted_sign, `name`, `type`,
  51. manager_id, dep_no, super_id,
  52. remarks, `status`, abbreviation,
  53. finance_id, province, working_hours_type,
  54. hide_sign, lvl, current_amount,
  55. subordinate_amount, total_amount, retrial_finance_id,
  56. approval, approval_aid, expense_finance_id,
  57. expense_retrial_finance_id)
  58. values (#{createId,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},
  59. #{deletedSign,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR},
  60. #{managerId,jdbcType=VARCHAR}, #{depNo,jdbcType=VARCHAR}, #{superId,jdbcType=VARCHAR},
  61. #{remarks,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{abbreviation,jdbcType=VARCHAR},
  62. #{financeId,jdbcType=VARCHAR}, #{province,jdbcType=INTEGER}, #{workingHoursType,jdbcType=INTEGER},
  63. #{hideSign,jdbcType=INTEGER}, #{lvl,jdbcType=INTEGER}, #{currentAmount,jdbcType=DECIMAL},
  64. #{subordinateAmount,jdbcType=DECIMAL}, #{totalAmount,jdbcType=DECIMAL}, #{retrialFinanceId,jdbcType=VARCHAR},
  65. #{approval,jdbcType=INTEGER}, #{approvalAid,jdbcType=VARCHAR}, #{expenseFinanceId,jdbcType=VARCHAR},
  66. #{expenseRetrialFinanceId,jdbcType=VARCHAR})
  67. </insert>
  68. <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.Department" useGeneratedKeys="true">
  69. insert into department
  70. <trim prefix="(" suffix=")" suffixOverrides=",">
  71. <if test="createId != null">
  72. create_id,
  73. </if>
  74. <if test="createTime != null">
  75. create_time,
  76. </if>
  77. <if test="updateTime != null">
  78. update_time,
  79. </if>
  80. <if test="deletedSign != null">
  81. deleted_sign,
  82. </if>
  83. <if test="name != null">
  84. `name`,
  85. </if>
  86. <if test="type != null">
  87. `type`,
  88. </if>
  89. <if test="managerId != null">
  90. manager_id,
  91. </if>
  92. <if test="depNo != null">
  93. dep_no,
  94. </if>
  95. <if test="superId != null">
  96. super_id,
  97. </if>
  98. <if test="remarks != null">
  99. remarks,
  100. </if>
  101. <if test="status != null">
  102. `status`,
  103. </if>
  104. <if test="abbreviation != null">
  105. abbreviation,
  106. </if>
  107. <if test="financeId != null">
  108. finance_id,
  109. </if>
  110. <if test="province != null">
  111. province,
  112. </if>
  113. <if test="workingHoursType != null">
  114. working_hours_type,
  115. </if>
  116. <if test="hideSign != null">
  117. hide_sign,
  118. </if>
  119. <if test="lvl != null">
  120. lvl,
  121. </if>
  122. <if test="currentAmount != null">
  123. current_amount,
  124. </if>
  125. <if test="subordinateAmount != null">
  126. subordinate_amount,
  127. </if>
  128. <if test="totalAmount != null">
  129. total_amount,
  130. </if>
  131. <if test="retrialFinanceId != null">
  132. retrial_finance_id,
  133. </if>
  134. <if test="approval != null">
  135. approval,
  136. </if>
  137. <if test="approvalAid != null">
  138. approval_aid,
  139. </if>
  140. <if test="expenseFinanceId != null">
  141. expense_finance_id,
  142. </if>
  143. <if test="expenseRetrialFinanceId != null">
  144. expense_retrial_finance_id,
  145. </if>
  146. </trim>
  147. <trim prefix="values (" suffix=")" suffixOverrides=",">
  148. <if test="createId != null">
  149. #{createId,jdbcType=VARCHAR},
  150. </if>
  151. <if test="createTime != null">
  152. #{createTime,jdbcType=TIMESTAMP},
  153. </if>
  154. <if test="updateTime != null">
  155. #{updateTime,jdbcType=TIMESTAMP},
  156. </if>
  157. <if test="deletedSign != null">
  158. #{deletedSign,jdbcType=INTEGER},
  159. </if>
  160. <if test="name != null">
  161. #{name,jdbcType=VARCHAR},
  162. </if>
  163. <if test="type != null">
  164. #{type,jdbcType=VARCHAR},
  165. </if>
  166. <if test="managerId != null">
  167. #{managerId,jdbcType=VARCHAR},
  168. </if>
  169. <if test="depNo != null">
  170. #{depNo,jdbcType=VARCHAR},
  171. </if>
  172. <if test="superId != null">
  173. #{superId,jdbcType=VARCHAR},
  174. </if>
  175. <if test="remarks != null">
  176. #{remarks,jdbcType=VARCHAR},
  177. </if>
  178. <if test="status != null">
  179. #{status,jdbcType=VARCHAR},
  180. </if>
  181. <if test="abbreviation != null">
  182. #{abbreviation,jdbcType=VARCHAR},
  183. </if>
  184. <if test="financeId != null">
  185. #{financeId,jdbcType=VARCHAR},
  186. </if>
  187. <if test="province != null">
  188. #{province,jdbcType=INTEGER},
  189. </if>
  190. <if test="workingHoursType != null">
  191. #{workingHoursType,jdbcType=INTEGER},
  192. </if>
  193. <if test="hideSign != null">
  194. #{hideSign,jdbcType=INTEGER},
  195. </if>
  196. <if test="lvl != null">
  197. #{lvl,jdbcType=INTEGER},
  198. </if>
  199. <if test="currentAmount != null">
  200. #{currentAmount,jdbcType=DECIMAL},
  201. </if>
  202. <if test="subordinateAmount != null">
  203. #{subordinateAmount,jdbcType=DECIMAL},
  204. </if>
  205. <if test="totalAmount != null">
  206. #{totalAmount,jdbcType=DECIMAL},
  207. </if>
  208. <if test="retrialFinanceId != null">
  209. #{retrialFinanceId,jdbcType=VARCHAR},
  210. </if>
  211. <if test="approval != null">
  212. #{approval,jdbcType=INTEGER},
  213. </if>
  214. <if test="approvalAid != null">
  215. #{approvalAid,jdbcType=VARCHAR},
  216. </if>
  217. <if test="expenseFinanceId != null">
  218. #{expenseFinanceId,jdbcType=VARCHAR},
  219. </if>
  220. <if test="expenseRetrialFinanceId != null">
  221. #{expenseRetrialFinanceId,jdbcType=VARCHAR},
  222. </if>
  223. </trim>
  224. </insert>
  225. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.Department">
  226. update department
  227. <set>
  228. <if test="createId != null">
  229. create_id = #{createId,jdbcType=VARCHAR},
  230. </if>
  231. <if test="createTime != null">
  232. create_time = #{createTime,jdbcType=TIMESTAMP},
  233. </if>
  234. <if test="updateTime != null">
  235. update_time = #{updateTime,jdbcType=TIMESTAMP},
  236. </if>
  237. <if test="deletedSign != null">
  238. deleted_sign = #{deletedSign,jdbcType=INTEGER},
  239. </if>
  240. <if test="name != null">
  241. `name` = #{name,jdbcType=VARCHAR},
  242. </if>
  243. <if test="type != null">
  244. `type` = #{type,jdbcType=VARCHAR},
  245. </if>
  246. <if test="managerId != null">
  247. manager_id = #{managerId,jdbcType=VARCHAR},
  248. </if>
  249. <if test="depNo != null">
  250. dep_no = #{depNo,jdbcType=VARCHAR},
  251. </if>
  252. <if test="superId != null">
  253. super_id = #{superId,jdbcType=VARCHAR},
  254. </if>
  255. <if test="remarks != null">
  256. remarks = #{remarks,jdbcType=VARCHAR},
  257. </if>
  258. <if test="status != null">
  259. `status` = #{status,jdbcType=VARCHAR},
  260. </if>
  261. <if test="abbreviation != null">
  262. abbreviation = #{abbreviation,jdbcType=VARCHAR},
  263. </if>
  264. <if test="financeId != null">
  265. finance_id = #{financeId,jdbcType=VARCHAR},
  266. </if>
  267. <if test="province != null">
  268. province = #{province,jdbcType=INTEGER},
  269. </if>
  270. <if test="workingHoursType != null">
  271. working_hours_type = #{workingHoursType,jdbcType=INTEGER},
  272. </if>
  273. <if test="hideSign != null">
  274. hide_sign = #{hideSign,jdbcType=INTEGER},
  275. </if>
  276. <if test="lvl != null">
  277. lvl = #{lvl,jdbcType=INTEGER},
  278. </if>
  279. <if test="currentAmount != null">
  280. current_amount = #{currentAmount,jdbcType=DECIMAL},
  281. </if>
  282. <if test="subordinateAmount != null">
  283. subordinate_amount = #{subordinateAmount,jdbcType=DECIMAL},
  284. </if>
  285. <if test="totalAmount != null">
  286. total_amount = #{totalAmount,jdbcType=DECIMAL},
  287. </if>
  288. <if test="retrialFinanceId != null">
  289. retrial_finance_id = #{retrialFinanceId,jdbcType=VARCHAR},
  290. </if>
  291. <if test="approval != null">
  292. approval = #{approval,jdbcType=INTEGER},
  293. </if>
  294. <if test="approvalAid != null">
  295. approval_aid = #{approvalAid,jdbcType=VARCHAR},
  296. </if>
  297. <if test="expenseFinanceId != null">
  298. expense_finance_id = #{expenseFinanceId,jdbcType=VARCHAR},
  299. </if>
  300. <if test="expenseRetrialFinanceId != null">
  301. expense_retrial_finance_id = #{expenseRetrialFinanceId,jdbcType=VARCHAR},
  302. </if>
  303. </set>
  304. where id = #{id,jdbcType=VARCHAR}
  305. </update>
  306. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.Department">
  307. update department
  308. set create_id = #{createId,jdbcType=VARCHAR},
  309. create_time = #{createTime,jdbcType=TIMESTAMP},
  310. update_time = #{updateTime,jdbcType=TIMESTAMP},
  311. deleted_sign = #{deletedSign,jdbcType=INTEGER},
  312. `name` = #{name,jdbcType=VARCHAR},
  313. `type` = #{type,jdbcType=VARCHAR},
  314. manager_id = #{managerId,jdbcType=VARCHAR},
  315. dep_no = #{depNo,jdbcType=VARCHAR},
  316. super_id = #{superId,jdbcType=VARCHAR},
  317. remarks = #{remarks,jdbcType=VARCHAR},
  318. `status` = #{status,jdbcType=VARCHAR},
  319. abbreviation = #{abbreviation,jdbcType=VARCHAR},
  320. finance_id = #{financeId,jdbcType=VARCHAR},
  321. province = #{province,jdbcType=INTEGER},
  322. working_hours_type = #{workingHoursType,jdbcType=INTEGER},
  323. hide_sign = #{hideSign,jdbcType=INTEGER},
  324. lvl = #{lvl,jdbcType=INTEGER},
  325. current_amount = #{currentAmount,jdbcType=DECIMAL},
  326. subordinate_amount = #{subordinateAmount,jdbcType=DECIMAL},
  327. total_amount = #{totalAmount,jdbcType=DECIMAL},
  328. retrial_finance_id = #{retrialFinanceId,jdbcType=VARCHAR},
  329. approval = #{approval,jdbcType=INTEGER},
  330. approval_aid = #{approvalAid,jdbcType=VARCHAR},
  331. expense_finance_id = #{expenseFinanceId,jdbcType=VARCHAR},
  332. expense_retrial_finance_id = #{expenseRetrialFinanceId,jdbcType=VARCHAR}
  333. where id = #{id,jdbcType=VARCHAR}
  334. </update>
  335. <select id="selectOrganizationList" parameterType="java.lang.String" resultType="com.goafanti.organization.bo.OrganizationListOut">
  336. select
  337. om.id,om.create_id as createId,om.create_time as createTime,
  338. om.update_time as updateTime,om.deleted_sign as deletedSign,
  339. om.name,om.type,
  340. om.dep_no as depNo,
  341. om.remarks,
  342. om.status,
  343. om.hide_sign hideSign ,
  344. om.approval,
  345. om.approval_aid approvalAid,
  346. dm.name as superName,
  347. wh.name as workingHoursName,
  348. x.name as managerName
  349. from department om
  350. left join department dm on om.super_id = dm.id
  351. left join admin x on om.manager_id = x.id
  352. left join working_hours wh on om.working_hours_type =wh.`type`
  353. where om.deleted_sign = 0
  354. <if test="name !=null">
  355. AND om.name like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
  356. </if>
  357. <if test="superId !=null">
  358. AND om.super_id=#{superId,jdbcType=VARCHAR}
  359. </if>
  360. <if test="type !=null">
  361. AND om.type=#{type,jdbcType=VARCHAR}
  362. </if>
  363. <if test="depNo !=null">
  364. AND om.dep_no=#{depNo,jdbcType=VARCHAR}
  365. </if>
  366. <if test="page_sql != null">
  367. ${page_sql}
  368. </if>
  369. </select>
  370. <select id="selectOrganizationCount" resultType="java.lang.Integer">
  371. select
  372. count(0)
  373. from department om
  374. left join department dm on om.super_id = dm.id
  375. left join admin x on om.manager_id = x.id
  376. where om.deleted_sign = 0
  377. <if test="name !=null">
  378. AND om.name like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
  379. </if>
  380. <if test="superId !=null">
  381. AND om.super_id=#{superId,jdbcType=VARCHAR}
  382. </if>
  383. <if test="type !=null">
  384. AND om.type=#{type,jdbcType=VARCHAR}
  385. </if>
  386. <if test="depNo !=null">
  387. AND om.dep_no=#{depNo,jdbcType=VARCHAR}
  388. </if>
  389. </select>
  390. <select id="selectSuperId" resultType="com.goafanti.organization.bo.DepOut">
  391. select
  392. id,name,dep_no as depNo,lvl,super_id superId
  393. from department
  394. where status ='0'
  395. <if test="lvl != null ">
  396. and lvl= #{lvl}
  397. </if>
  398. <if test="hideSign != null ">
  399. and hide_sign= #{hideSign}
  400. </if>
  401. <if test="id != null ">
  402. and super_id= #{id}
  403. </if>
  404. order by depNo
  405. </select>
  406. <!-- 得到上级 -->
  407. <select id="selectDepNo" resultType="java.lang.String">
  408. select
  409. dep_no as depNo
  410. from department
  411. where
  412. id=#{superId,jdbcType=VARCHAR}
  413. </select>
  414. <select id="selectDepNoByName" resultType="java.lang.String">
  415. select
  416. dep_no as depNo
  417. from department
  418. where
  419. name=#{name,jdbcType=VARCHAR}
  420. </select>
  421. <select id="selectDepNoCount" parameterType="java.lang.String" resultType="java.lang.Integer">
  422. select
  423. count(0)
  424. from department
  425. where
  426. <!-- dep_no like concat(#{depNo,jdbcType=VARCHAR},'%') -->
  427. super_id=#{superId,jdbcType=VARCHAR}
  428. </select>
  429. <select id="selectName" resultType="com.goafanti.admin.bo.AdminListBo">
  430. select
  431. name,id
  432. from admin
  433. where status= 0
  434. and name like concat('%',#{name,jdbcType=VARCHAR},'%')
  435. </select>
  436. <select id="selectAllById" resultType="com.goafanti.organization.bo.OrganizationListOut">
  437. select a.id, a.create_id as createId, a.create_time as createTime, a.update_time as updateTime,a.retrial_finance_id retrialFinanceId,
  438. d.name retrialFinanceName, a.deleted_sign as deletedSign, a.name, a.type, a.manager_id as managerId, a.dep_no as depNo,
  439. a.super_id as superId, a.remarks, a.status, a.abbreviation, a.finance_id financeId,a.hide_sign hideSign,
  440. a.expense_finance_id expenseFinanceId,f.name expenseFinanceName,a.expense_retrial_finance_id expenseRetrialFinanceId,
  441. g.name expenseRetrialFinanceName, a.province, c.name financeName, a.working_hours_type workingHoursType, b.name as managerName,
  442. a.retrial_finance_id retrialFinanceId, d.name retrialFinanceName,a.approval,a.approval_aid approvalAid,e.name approvalName
  443. from department a left join admin b on a.manager_id = b.id left join admin c on a.finance_id = c.id
  444. left join admin d on a.retrial_finance_id=d.id left join admin e on a.approval_aid =e.id
  445. left join admin f on a.expense_finance_id=f.id left join admin g on a.expense_retrial_finance_id=g.id
  446. where a.id=#{id,jdbcType=VARCHAR}
  447. </select>
  448. <delete id="deleteById" parameterType="java.lang.String">
  449. delete from department
  450. where id = #{id,jdbcType=VARCHAR}
  451. </delete>
  452. <select id="selectAdminNameById" parameterType="java.lang.String" resultType="java.lang.String">
  453. select
  454. name
  455. from admin
  456. where
  457. id=#{id,jdbcType=VARCHAR}
  458. </select>
  459. <select id="selectIdByDepNo" parameterType="java.lang.String" resultType="java.lang.String">
  460. select
  461. id
  462. from department
  463. where
  464. dep_no=#{depNo,jdbcType=VARCHAR}
  465. </select>
  466. <select id="selectIDNBySuperId" parameterType="java.lang.String" resultType="com.goafanti.organization.bo.OrganizationListOut">
  467. select
  468. id,create_id as createId,create_time as createTime,
  469. update_time as updateTime,deleted_sign as deletedSign,
  470. name,type,manager_id as managerId,
  471. dep_no as depNo,
  472. super_id as superId,
  473. remarks,status
  474. from department
  475. where
  476. super_id=#{id,jdbcType=VARCHAR}
  477. order by dep_no
  478. </select>
  479. <update id="updateByNumber" parameterType="com.goafanti.organization.bo.OrganizationListOut">
  480. update department
  481. <set>
  482. dep_no = #{depNo,jdbcType=VARCHAR},
  483. lvl= #{lvl}
  484. </set>
  485. where
  486. id=#{id,jdbcType=VARCHAR}
  487. </update>
  488. <select id="selectCountBySuperId" parameterType="java.lang.String" resultType="java.lang.Integer">
  489. select
  490. count(0)
  491. from department
  492. where
  493. super_id=#{superId,jdbcType=VARCHAR}
  494. </select>
  495. <select id="selectIdByName" parameterType="java.lang.String" resultType="java.lang.String">
  496. select
  497. id
  498. from department
  499. where
  500. name=#{name,jdbcType=VARCHAR}
  501. </select>
  502. <select id="selectNameById" parameterType="java.lang.String" resultType="java.lang.String">
  503. select
  504. name
  505. from department
  506. where
  507. id=#{id,jdbcType=VARCHAR}
  508. </select>
  509. <select id="selectDepNoById" resultType="java.lang.String">
  510. select
  511. dep_no as depNo
  512. from department
  513. where
  514. id=#{id,jdbcType=VARCHAR}
  515. </select>
  516. <select id="selectUserById" parameterType="java.lang.String" resultType="java.lang.Integer">
  517. select
  518. count(0)
  519. from admin
  520. where
  521. department_id=#{id,jdbcType=VARCHAR}
  522. </select>
  523. <!-- 查询当前层级 -->
  524. <select id="selectCurrentDeps" parameterType="java.lang.String" resultType="string">
  525. select id from department where manager_id = #{aid,jdbcType=VARCHAR}
  526. union
  527. select id from department where id = (select department_id from admin where id = #{aid,jdbcType=VARCHAR})
  528. </select>
  529. <!-- 查询下一层级 -->
  530. <select id="selectSubDeps" parameterType="java.lang.String" resultType="string">
  531. select id from department where super_id in (#{superIds,jdbcType=VARCHAR})
  532. </select>
  533. <!-- 查询下一层级 -->
  534. <select id="selectSubDepsList" parameterType="java.lang.String" resultType="com.goafanti.common.model.Department">
  535. select id from department where super_id in (#{superIds,jdbcType=VARCHAR})
  536. </select>
  537. <select id="selectBysuperId" resultType="com.goafanti.admin.bo.DepCountBo">
  538. select a.id ,a.name ,0 userCount,0 inputCount,0 receiveCount, 0 completeCount, 0 interviewCount
  539. from department a where a.super_id= #{id}
  540. </select>
  541. <select id="selectBysuperName" resultType="com.goafanti.admin.bo.DepCountBo">
  542. select a.id ,a.name ,0 userCount,0 inputCount,0 receiveCount, 0 completeCount, 0 interviewCount
  543. from department a left join department b on a.super_id=b.id where b.name= #{name}
  544. </select>
  545. <!-- 查询所有 -->
  546. <select id="selectAllDeps" resultType="com.goafanti.common.model.Department">
  547. select id ,super_id superId
  548. from department
  549. </select>
  550. <select id="getMaxAbbreviation" parameterType="java.lang.String" resultType="java.lang.String">
  551. select max(contract_no) as maxNo from t_order_new
  552. where create_time > '2019-5-31'
  553. and contract_no like concat(#{abbreviation,jdbcType=VARCHAR},'%')
  554. </select>
  555. <select id="getDepAll" resultType="com.goafanti.admin.bo.AdminCustomerBo">
  556. select a.id aid,a.name aName,d.id depId,d.name depName,ifnull(b.userCount,0)userCount,ifnull(b.channelCount,0)channelCount,
  557. ifnull(b.signCount,0)signCount,ifnull(b.newCount,0)newCount,ifnull(b.channelNewCount,0)channelNewCount,ifnull( b.receiveCount,0)receiveCount,
  558. ifnull( b.completeCount,0)completeCount,ifnull(b.channelCompleteCount,0)channelCompleteCount
  559. from admin a left join (select x.aid,x.userCount,x.channelCount,signCount,x.newCount,x.channelNewCount,x.receiveCount,
  560. ifnull(y.completeCount,0)completeCount,ifnull(y.channelCompleteCount,0)channelCompleteCount
  561. from (select aid,sum(if( share_type=0 and channel=0,1,0))userCount,
  562. sum(if(share_type=3 and channel=1,1,0))channelCount,
  563. sum(if( share_type=2 ,1,0))signCount,
  564. sum(if(share_type=0 and source =1 and channel=0,1,0))newCount,
  565. sum(if(share_type=0 and source =1 and channel=1,1,0))channelNewCount,
  566. sum(if(share_type=0 and source =2 and channel=0,1,0))receiveCount
  567. from `user` where `type` =1 and new_channel=0
  568. <if test="startTime != null and endTime != null">
  569. and transfer_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  570. </if>
  571. group by aid)x left join (select a.aid,sum(if(b.channel=0,1,0))completeCount,
  572. sum(if(b.channel=1,1,0))channelCompleteCount from public_release a left join public_release_details prd on a.id=prd.id
  573. left join `user` b on prd.uid =b.id
  574. where prd.clock_in =1
  575. <if test="startTime != null and endTime != null">
  576. and prd.clock_in_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  577. </if>
  578. group by a.aid ) y on x.aid=y.aid)b on a.id=b.aid
  579. left join department d on a.department_id=d.id
  580. where a.status= 0 and a.type=1
  581. <if test="adminName !=null">
  582. and a.name like concat('%',#{adminName},'%')
  583. </if>
  584. <if test="depId !=null">
  585. and d.id= #{depId}
  586. </if>
  587. </select>
  588. <select id="AlldepCount" resultType="com.goafanti.admin.bo.AdminCustomerBo">
  589. select a.id aid,a.name aName ,a.department_id depId,c.name depName,ifnull(userCount,0)userCount,
  590. ifnull(channelCount,0)channelCount,ifnull(signCount,0)signCount,ifnull(newCount,0)newCount,
  591. ifnull(channelNewCount,0)channelNewCount,ifnull(receiveCount,0)receiveCount,ifnull(completeCount,0)completeCount,
  592. ifnull(channelCompleteCount,0)channelCompleteCount
  593. from admin a left join (select aid,sum(if( share_type=0 and channel=0,1,0))userCount,
  594. sum(if(share_type=3 and channel=1,1,0))channelCount,
  595. sum(if( share_type=2 ,1,0))signCount,
  596. sum(if(share_type=0 and source =1 and channel=0,1,0))newCount,
  597. sum(if(share_type=0 and source =1 and channel=1,1,0))channelNewCount,
  598. sum(if(share_type=0 and source =2 and channel=0,1,0))receiveCount
  599. from `user` where `type` =1 and new_channel=0
  600. <if test="startTime != null and endTime != null">
  601. and transfer_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  602. </if>
  603. group by aid)b on a.id=b.aid
  604. left join (select a.aid,sum(if(c.channel=0,1,0))completeCount,
  605. sum(if(c.channel=1,1,0))channelCompleteCount
  606. from public_release a left join public_release_details b on a.id=b.prid left join `user` c on b.uid=c.id
  607. where b.clock_in =1
  608. <if test="startTime != null and endTime != null">
  609. and b.clock_in_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  610. </if>
  611. group by a.aid ) y on a.id=y.aid
  612. left join department c on a.department_id =c.id
  613. where a.status= 0 and a.type=1
  614. <if test="depIds!= null">
  615. and a.department_id in
  616. <foreach close=")" collection="depIds" item="deps" open="(" separator=",">
  617. #{deps.id}
  618. </foreach>
  619. </if>
  620. </select>
  621. <select id="selectByDepNo" resultMap="BaseResultMap">
  622. select
  623. <include refid="Base_Column_List"/>
  624. from department where super_id= #{superId}
  625. order by dep_no desc limit 1
  626. </select>
  627. <update id="updateDepFinance">
  628. update department
  629. set finance_id= #{transferId}
  630. where finance_id= #{aid}
  631. </update>
  632. </mapper>