DepartmentMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  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="DepartmentMapper">
  4. <resultMap type="Department" id="departmentResultMap">
  5. <id column="DEPARTMENT_ID" property="DEPARTMENT_ID"/>
  6. <result column="NAME" property="NAME"/>
  7. <result column="PARENT_ID" property="PARENT_ID"/>
  8. </resultMap>
  9. <!--表名 -->
  10. <sql id="tableName">
  11. OA_DEPARTMENT
  12. </sql>
  13. <!--表名 -->
  14. <sql id="tableName2">
  15. OA_DEPARTMENT_2
  16. </sql>
  17. <!-- 字段 -->
  18. <sql id="Field">
  19. NAME,
  20. NAME_EN,
  21. BIANMA,
  22. UNI_CODE,
  23. PARENT_ID,
  24. HEADMAN,
  25. TEL,
  26. FUNCTIONS,
  27. ADDRESS,
  28. BZ,
  29. DEPARTMENT_ID,
  30. YEAR,
  31. SHOW_NUM,
  32. STATUS,
  33. CREATETIME,
  34. UPDATETIME
  35. </sql>
  36. <!-- 字段值 -->
  37. <sql id="FieldValue">
  38. #{NAME},
  39. #{NAME_EN},
  40. #{BIANMA},
  41. #{UNI_CODE},
  42. #{PARENT_ID},
  43. #{HEADMAN},
  44. #{TEL},
  45. #{FUNCTIONS},
  46. #{ADDRESS},
  47. #{BZ},
  48. #{DEPARTMENT_ID},
  49. #{YEAR},
  50. #{SHOW_NUM},
  51. #{STATUS},
  52. #{CREATETIME},
  53. #{UPDATETIME}
  54. </sql>
  55. <!-- 新增-->
  56. <insert id="save" parameterType="pd">
  57. insert into
  58. <include refid="tableName"></include>
  59. (
  60. <include refid="Field"></include>
  61. ) values (
  62. <include refid="FieldValue"></include>
  63. )
  64. </insert>
  65. <!-- 新增动态-->
  66. <insert id="saveYear" parameterType="pd">
  67. insert into
  68. ${table}
  69. (
  70. <include refid="Field"></include>
  71. ) values (
  72. <include refid="FieldValue"></include>
  73. )
  74. ON DUPLICATE KEY UPDATE
  75. NAME = VALUES(NAME),
  76. NAME_EN = VALUES(NAME_EN),
  77. BIANMA = VALUES(BIANMA),
  78. UNI_CODE = VALUES(UNI_CODE),
  79. PARENT_ID = VALUES(PARENT_ID),
  80. HEADMAN = VALUES(HEADMAN),
  81. TEL = VALUES(TEL),
  82. FUNCTIONS = VALUES(FUNCTIONS),
  83. ADDRESS = VALUES(ADDRESS),
  84. BZ = VALUES(BZ),
  85. YEAR = VALUES(YEAR),
  86. STATUS = VALUES(STATUS),
  87. CREATETIME = VALUES(CREATETIME),
  88. UPDATETIME = VALUES(UPDATETIME);
  89. </insert>
  90. <!-- 删除-->
  91. <delete id="delete" parameterType="pd">
  92. delete from
  93. <include refid="tableName"></include>
  94. where
  95. DEPARTMENT_ID = #{DEPARTMENT_ID}
  96. </delete>
  97. <!-- 修改 -->
  98. <update id="edit" parameterType="pd">
  99. update
  100. <include refid="tableName"></include>
  101. set
  102. NAME = #{NAME},
  103. NAME_EN = #{NAME_EN},
  104. HEADMAN = #{HEADMAN},
  105. BZ = #{BZ},
  106. TEL = #{TEL},
  107. FUNCTIONS = #{FUNCTIONS},
  108. ADDRESS = #{ADDRESS},
  109. DEPARTMENT_ID = DEPARTMENT_ID
  110. where
  111. DEPARTMENT_ID = #{DEPARTMENT_ID}
  112. </update>
  113. <!-- 动态年份修改 -->
  114. <update id="editYear" parameterType="pd">
  115. update
  116. ${table}
  117. set
  118. NAME = #{NAME},
  119. NAME_EN = #{NAME_EN},
  120. HEADMAN = #{HEADMAN},
  121. BZ = #{BZ},
  122. TEL = #{TEL},
  123. FUNCTIONS = #{FUNCTIONS},
  124. ADDRESS = #{ADDRESS},
  125. DEPARTMENT_ID = DEPARTMENT_ID
  126. where
  127. DEPARTMENT_ID = #{DEPARTMENT_ID}
  128. </update>
  129. <!--修改状态 -->
  130. <update id="updateStatus" parameterType="pd">
  131. update
  132. <include refid="tableName"></include>
  133. set
  134. STATUS = '0'
  135. where
  136. DEPARTMENT_ID = #{DEPARTMENT_ID}
  137. </update>
  138. <!--修改状态动态 -->
  139. <update id="updateYearStatus" parameterType="pd">
  140. update
  141. ${table}
  142. set
  143. STATUS = '0'
  144. where
  145. DEPARTMENT_ID = #{DEPARTMENT_ID}
  146. </update>
  147. <!-- 通过ID获取数据 -->
  148. <select id="findById" parameterType="pd" resultType="pd">
  149. select
  150. <include refid="Field"></include>
  151. from
  152. <include refid="tableName"></include>
  153. where
  154. DEPARTMENT_ID = #{DEPARTMENT_ID}
  155. AND STATUS='1'
  156. </select>
  157. <!-- 通过编码获取数据 -->
  158. <select id="findByBianma" parameterType="pd" resultType="pd">
  159. select
  160. <include refid="Field"></include>
  161. from
  162. <include refid="tableName"></include>
  163. where BIANMA = #{BIANMA}
  164. </select>
  165. <!-- 通过统一编码获取数据 -->
  166. <select id="findByUniCode" parameterType="pd" resultType="pd">
  167. select
  168. <include refid="Field"></include>
  169. from
  170. <include refid="tableName"></include>
  171. where UNI_CODE = #{UNI_CODE}
  172. </select>
  173. <!-- 通过编码获取数据(表department2) -->
  174. <!-- <select id="findByBianma2" parameterType="pd" resultType="pd">
  175. select
  176. <include refid="Field"></include>
  177. from
  178. <include refid="tableName2"></include>
  179. where
  180. BIANMA = #{BIANMA}
  181. </select> -->
  182. <select id="findByBianma2" parameterType="pd" resultType="pd">
  183. select
  184. <include refid="Field"></include>
  185. from
  186. ${table}
  187. where
  188. BIANMA = #{BIANMA}
  189. </select>
  190. <!-- 列表 -->
  191. <select id="datalistPage" parameterType="page" resultType="pd">
  192. select
  193. <include refid="Field"></include>
  194. from
  195. <include refid="tableName"></include>
  196. where
  197. 1=1 AND STATUS='1'
  198. <if test="pd.DEPARTMENT_ID!= null and pd.DEPARTMENT_ID != ''"><!-- 检索 -->
  199. and PARENT_ID = #{pd.DEPARTMENT_ID}
  200. </if>
  201. <if test="pd.keywords != null and pd.keywords != ''"><!-- 关键词检索 -->
  202. and
  203. (
  204. NAME LIKE CONCAT(CONCAT('%', #{pd.keywords}),'%')
  205. or
  206. NAME_EN LIKE CONCAT(CONCAT('%', #{pd.keywords}),'%')
  207. or
  208. BIANMA LIKE CONCAT(CONCAT('%', #{pd.keywords}),'%')
  209. or
  210. UNI_CODE LIKE CONCAT(CONCAT('%', #{pd.keywords}),'%')
  211. )
  212. </if>
  213. ORDER BY (BIANMA+0) ASC
  214. <!-- order by NAME -->
  215. </select>
  216. <!-- 通过ID获取其子级列表 -->
  217. <select id="listSubDepartmentByParentId" parameterType="String" resultMap="departmentResultMap">
  218. select
  219. <include refid="Field"></include>
  220. from
  221. <include refid="tableName"></include>
  222. where
  223. PARENT_ID = #{parentId}
  224. AND STATUS='1'
  225. ORDER BY (BIANMA+0) ASC
  226. <!-- order by NAME -->
  227. </select>
  228. <!-- 通过ID获取其子级列表 -->
  229. <select id="listSubDepartmentByParentId2" parameterType="String" resultMap="departmentResultMap">
  230. select
  231. <include refid="Field"></include>
  232. from
  233. <include refid="tableName2"></include>
  234. where
  235. PARENT_ID = #{parentId}
  236. ORDER BY (BIANMA+0) ASC
  237. <!-- order by NAME -->
  238. </select>
  239. <select id="getdep2" parameterType="String" resultType="String">
  240. select
  241. dep2_id
  242. from
  243. oa_department_relation
  244. where
  245. dep1_id = #{depId}
  246. </select>
  247. <!-- fh313596790qq(青苔) -->
  248. <insert id="saveAPIrecord" parameterType="pd">
  249. insert into oa_department_2(
  250. DEPARTMENT_ID,NAME,BIANMA,PARENT_ID
  251. ) values (
  252. #{DEPARTMENT_ID},#{NAME},#{BIANMA},#{PARENT_ID}
  253. )
  254. </insert>
  255. <!-- 删除-->
  256. <delete id="deleteCompany" parameterType="String">
  257. delete from
  258. oa_department_2
  259. where
  260. BIANMA = #{BIANMA}
  261. </delete>
  262. <!-- 修改 -->
  263. <update id="updateCompany" parameterType="pd">
  264. update
  265. <include refid="tableName2"></include>
  266. set
  267. NAME = #{NAME},
  268. DEPARTMENT_ID = #{DEPARTMENT_ID},
  269. PARENT_ID = #{PARENT_ID}
  270. where
  271. BIANMA = #{BIANMA}
  272. </update>
  273. <!-- 删除-->
  274. <delete id="deleteDep1" parameterType="String">
  275. delete from
  276. oa_department_relation
  277. where
  278. dep1_id = #{dep1_id}
  279. </delete>
  280. <!-- 使用foreach批量插入-->
  281. <insert id="addDep1and2" parameterType="pd">
  282. insert into
  283. oa_department_relation
  284. (
  285. dep1_id, dep2_id,comp1_id,comp2_id,route_no,company_name
  286. )
  287. values
  288. <foreach collection="list" item="pd" separator=",">
  289. (#{pd.leftnode}, #{pd.rightnode},#{pd.leftcompanyid}, #{pd.rightcompanyid},#{pd.rightroadno},#{pd.leftcompanyname})
  290. </foreach>
  291. </insert>
  292. <!-- 通过公司id、高速公路id、桩号id查询记录 -->
  293. <select id="findByStakeNo" parameterType="pd" resultType="pd">
  294. select
  295. GUID,ROAD_NO,STAKE_NO,LONGITUDE,LATITUDE,ROAD_COMP_ID,ROAD_BRIDGE_NAME,NAME_ABBREVIATION
  296. from
  297. zg_route_stake_manage
  298. where
  299. GUID = #{GUID}
  300. </select>
  301. <insert id="saveStakeRecord" parameterType="pd">
  302. insert into zg_route_stake_manage(
  303. GUID,ROAD_NO,STAKE_NO,LONGITUDE,LATITUDE,ROAD_COMP_ID
  304. ) values (
  305. #{GUID},#{ROAD_NO},#{STAKE_NO},#{LONGITUDE},#{LATITUDE},#{ROAD_COMP_ID}
  306. )
  307. </insert>
  308. <!-- 删除-->
  309. <delete id="deleteStakeRecord" parameterType="String">
  310. delete from
  311. zg_route_stake_manage
  312. where
  313. GUID = #{GUID}
  314. </delete>
  315. <!-- 修改 -->
  316. <update id="updateStakeRecord" parameterType="pd">
  317. update
  318. zg_route_stake_manage
  319. set
  320. GUID = #{GUID},
  321. ROAD_NO = #{ROAD_NO},
  322. STAKE_NO = #{STAKE_NO},
  323. LONGITUDE = #{LONGITUDE},
  324. LATITUDE = #{LATITUDE},
  325. ROAD_COMP_ID = #{ROAD_COMP_ID}
  326. where
  327. GUID = #{GUID}
  328. </update>
  329. <!-- 根据对应关系查询路公司和高速公路信息 -->
  330. <select id="findRoadInfo" parameterType="pd" resultType="pd">
  331. select
  332. NAME,BIANMA,PARENT_ID
  333. from
  334. oa_department
  335. where
  336. DEPARTMENT_ID = #{leftnode}
  337. </select>
  338. <!-- 查询路公司名称 -->
  339. <select id="findCompanyName" parameterType="pd" resultType="String">
  340. select
  341. NAME
  342. from
  343. oa_department
  344. where
  345. DEPARTMENT_ID = #{PARENT_ID}
  346. </select>
  347. <!-- 查询路公司名称 -->
  348. <select id="findGUID" parameterType="pd" resultType="String">
  349. select
  350. a.GUID
  351. from
  352. zg_route_stake_manage a
  353. oa_department_2 b
  354. where
  355. a.ROAD_NO = b.BIANMA
  356. b.DEPARTMENT_ID = #{rightnode}
  357. </select>
  358. <!-- 根据对应关系修改桩号表中路公司和高速公路信息 -->
  359. <update id="updateStake" parameterType="pd">
  360. update
  361. zg_route_stake_manage
  362. set
  363. ROAD_COMP_ID = #{leftcompanyid},
  364. ROAD_BRIDGE_NAME = #{leftcompanyname}
  365. where
  366. ROAD_NO = #{rightroadno}
  367. </update>
  368. <!-- 查询路公司名称 -->
  369. <select id="findCompanyinfo" parameterType="String" resultType="pd">
  370. select
  371. DEPARTMENT_ID, NAME
  372. from
  373. oa_department
  374. where
  375. DEPARTMENT_ID =
  376. (
  377. select
  378. PARENT_ID
  379. from
  380. oa_department
  381. where
  382. DEPARTMENT_ID = #{leftnode}
  383. )
  384. </select>
  385. <select id="findCompanyinfo2" parameterType="pd" resultType="pd">
  386. select
  387. PARENT_ID, BIANMA
  388. from
  389. oa_department_2
  390. where
  391. DEPARTMENT_ID = #{rightnode}
  392. </select>
  393. <select id="findUser2byComp" parameterType="pd" resultType="pd">
  394. select
  395. *
  396. from
  397. sys_user_2
  398. where
  399. COMPANY_ID = #{rightcompanyid}
  400. </select>
  401. <select id="findAllUser" parameterType="pd" resultType="pd">
  402. select
  403. *
  404. from
  405. sys_user
  406. </select>
  407. <insert id="addNewUser" parameterType="pd">
  408. insert sys_user(
  409. USER_ID,USERNAME,PASSWORD,NAME,RIGHTS,ROLE_ID,LAST_LOGIN,IP,STATUS,BZ,SKIN,EMAIL,NUMBER,PHONE,ROLE_IDS,COMPANY,ROAD
  410. ) values (
  411. #{USER_ID},#{USERNAME},#{PASSWORD},#{NAME},#{RIGHTS},#{ROLE_ID},#{LAST_LOGIN},#{IP},#{STATUS},#{BZ},#{SKIN},#{EMAIL}
  412. ,#{NUMBER},#{PHONE},#{ROLE_IDS},#{COMPANY},#{ROAD}
  413. )
  414. </insert>
  415. <!-- 年度树结构 -->
  416. <select id="yearListSubDepartmentByParentId" parameterType="pd" resultMap="departmentResultMap">
  417. select
  418. <include refid="Field"></include>
  419. from
  420. ${table}
  421. where
  422. PARENT_ID = #{parentId}
  423. AND STATUS='1'
  424. ORDER BY (BIANMA+0) ASC
  425. <!-- order by NAME -->
  426. </select>
  427. <!-- 年度列表 -->
  428. <select id="yeardatalistPage" parameterType="page" resultType="pd">
  429. select
  430. <include refid="Field"></include>
  431. from
  432. ${pd.table}
  433. where
  434. 1=1 AND STATUS='1'
  435. <if test="pd.DEPARTMENT_ID!= null and pd.DEPARTMENT_ID != ''"><!-- 检索 -->
  436. and PARENT_ID = #{pd.DEPARTMENT_ID}
  437. </if>
  438. <if test="pd.keywords != null and pd.keywords != ''"><!-- 关键词检索 -->
  439. and
  440. (
  441. NAME LIKE CONCAT(CONCAT('%', #{pd.keywords}),'%')
  442. or
  443. NAME_EN LIKE CONCAT(CONCAT('%', #{pd.keywords}),'%')
  444. or
  445. BIANMA LIKE CONCAT(CONCAT('%', #{pd.keywords}),'%')
  446. )
  447. </if>
  448. ORDER BY (BIANMA+0) ASC
  449. <!-- order by NAME -->
  450. </select>
  451. <!-- 通过ID获取数据 -->
  452. <select id="yearFindById" parameterType="pd" resultType="pd">
  453. select
  454. <include refid="Field"></include>
  455. from
  456. ${table}
  457. where
  458. DEPARTMENT_ID = #{DEPARTMENT_ID}
  459. </select>
  460. <!-- 查询对应年份表是否存在 -->
  461. <select id="countYearTable" parameterType="pd" resultType="Integer">
  462. SELECT
  463. count(*)
  464. FROM
  465. information_schema. TABLES t
  466. WHERE
  467. t.TABLE_SCHEMA = "gsyh"
  468. AND t.TABLE_NAME = #{table};
  469. </select>
  470. <!-- 创建动态表格 -->
  471. <update id="createYearTable" parameterType="pd">
  472. CREATE TABLE ${table} LIKE oa_department ;
  473. </update>
  474. <!-- 通过ID获取数据 -->
  475. <select id="yearQuery" parameterType="pd" resultType="pd">
  476. select
  477. <include refid="Field"></include>
  478. from
  479. ${table}
  480. where
  481. STATUS='1'
  482. ORDER BY (BIANMA+0) ASC
  483. <!-- order by NAME -->
  484. </select>
  485. <!-- 年份表删除-->
  486. <delete id="yearDelete" parameterType="pd">
  487. delete from ${table}
  488. where
  489. DEPARTMENT_ID = #{DEPARTMENT_ID}
  490. </delete>
  491. <!-- 获取路公司 -->
  492. <select id="queryByParentId" parameterType="String" resultMap="departmentResultMap">
  493. select
  494. <include refid="Field"></include>
  495. from
  496. ${table}
  497. where
  498. PARENT_ID = '0'
  499. ORDER BY (BIANMA+0) ASC
  500. </select>
  501. <!-- 获取bianma -->
  502. <select id="queryBianma" parameterType="pd" resultType="java.lang.String">
  503. select
  504. BIANMA
  505. from
  506. ${table}
  507. where
  508. uni_code LIKE CONCAT(CONCAT('%', #{routeCode}),'%')
  509. </select>
  510. </mapper>