SysOrgMapper.xml 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.xunmei.system.mapper.SysOrgMapper">
  6. <resultMap type="com.xunmei.system.api.domain.SysOrg" id="SysOrgResult">
  7. <result property="id" column="id"/>
  8. <result property="address" column="address"/>
  9. <result property="code" column="code"/>
  10. <result property="guid" column="guid"/>
  11. <result property="isLock" column="is_lock"/>
  12. <result property="manager" column="manager"/>
  13. <result property="managerPhone" column="manager_phone"/>
  14. <result property="name" column="name"/>
  15. <result property="parentId" column="parent_id"/>
  16. <result property="phone" column="phone"/>
  17. <result property="cityCode" column="city_code"/>
  18. <result property="type" column="type"/>
  19. <result property="createTime" column="create_time"/>
  20. <result property="updateTime" column="update_time"/>
  21. <result property="path" column="path"/>
  22. <result property="parentGuid" column="parent_guid"/>
  23. <result property="deleted" column="deleted"/>
  24. <result property="sort" column="sort"/>
  25. <result property="source" column="source"/>
  26. <result property="shortName" column="short_name"/>
  27. <result property="remark" column="remark"/>
  28. <result property="source" column="source"/>
  29. <result property="createBy" column="create_by"/>
  30. <result property="updateBy" column="update_by"/>
  31. <result property="treeShowParentId" column="tree_show_parent_id"/>
  32. <result property="treeShowPath" column="tree_show_path"/>
  33. </resultMap>
  34. <sql id="selectSysOrgVo">
  35. select id,
  36. address,
  37. code,
  38. guid,
  39. is_lock,
  40. manager,
  41. manager_phone,
  42. name,
  43. parent_id,
  44. phone,
  45. city_code,
  46. type,
  47. create_time,
  48. update_time,
  49. parent_guid,
  50. deleted,
  51. sort,
  52. create_by,
  53. update_by,
  54. org_extend_id,
  55. source,
  56. short_name,
  57. remark,
  58. path,
  59. tree_show_parent_id,
  60. tree_show_path
  61. from sys_org
  62. </sql>
  63. <select id="selectSysOrgList" parameterType="com.xunmei.system.api.domain.SysOrg"
  64. resultMap="SysOrgResult">
  65. <include refid="selectSysOrgVo"/>
  66. <where>
  67. <if test="address != null and address != ''">
  68. and address = #{address}
  69. </if>
  70. <if test="code != null and code != ''">
  71. and code = #{code}
  72. </if>
  73. <!-- <if test="deviceCount != null ">-->
  74. <!-- and device_count = #{deviceCount}-->
  75. <!-- </if>-->
  76. <if test="guid != null and guid != ''">
  77. and guid = #{guid}
  78. </if>
  79. <if test="isLock != null ">
  80. and is_lock = #{isLock}
  81. </if>
  82. <if test="manager != null and manager != ''">
  83. and manager = #{manager}
  84. </if>
  85. <if test="managerPhone != null and managerPhone != ''">
  86. and manager_phone = #{managerPhone}
  87. </if>
  88. <if test="name != null and name != ''">
  89. and name like concat('%', #{name}, '%')
  90. </if>
  91. <if test="parentId != null ">
  92. and parent_id = #{parentId}
  93. </if>
  94. <if test="phone != null and phone != ''">
  95. and phone = #{phone}
  96. </if>
  97. <if test="cityCode != null and cityCode != ''">
  98. and city_code = #{cityCode}
  99. </if>
  100. <!-- <if test="openYear != null ">-->
  101. <!-- and open_year = #{openYear}-->
  102. <!-- </if>-->
  103. <!-- <if test="fitYear != null ">-->
  104. <!-- and fit_year = #{fitYear}-->
  105. <!-- </if>-->
  106. <!-- <if test="floorage != null and floorage != ''">-->
  107. <!-- and floorage = #{floorage}-->
  108. <!-- </if>-->
  109. <!-- <if test="employee != null ">-->
  110. <!-- and employee = #{employee}-->
  111. <!-- </if>-->
  112. <!-- <if test="isOwnRight != null ">-->
  113. <!-- and is_own_right = #{isOwnRight}-->
  114. <!-- </if>-->
  115. <!-- <if test="isRent != null ">-->
  116. <!-- and is_rent = #{isRent}-->
  117. <!-- </if>-->
  118. <!-- <if test="isOnly != null ">-->
  119. <!-- and is_only = #{isOnly}-->
  120. <!-- </if>-->
  121. <!-- <if test="buildYear != null ">-->
  122. <!-- and build_year = #{buildYear}-->
  123. <!-- </if>-->
  124. <!-- <if test="placeType != null ">-->
  125. <!-- and place_type = #{placeType}-->
  126. <!-- </if>-->
  127. <!-- <if test="buildHeight != null ">-->
  128. <!-- and build_height = #{buildHeight}-->
  129. <!-- </if>-->
  130. <!-- <if test="social != null ">-->
  131. <!-- and social = #{social}-->
  132. <!-- </if>-->
  133. <!-- <if test="naturalEnvir != null ">-->
  134. <!-- and natural_envir = #{naturalEnvir}-->
  135. <!-- </if>-->
  136. <if test="type != null ">
  137. and type = #{type}
  138. </if>
  139. <if test="updateBy != null and updateBy != ''">
  140. and update_by like concat('%', #{updateBy}, '%')
  141. </if>
  142. <!-- <if test="modifiedId != null ">-->
  143. <!-- and modified_id = #{modifiedId}-->
  144. <!-- </if>-->
  145. <if test="path != null and path != ''">
  146. and path = #{path}
  147. </if>
  148. <!-- <if test="vid != null ">-->
  149. <!-- and vid = #{vid}-->
  150. <!-- </if>-->
  151. <!-- <if test="level != null ">-->
  152. <!-- and level = #{level}-->
  153. <!-- </if>-->
  154. <!-- <if test="oid != null and oid != ''">-->
  155. <!-- and oid = #{oid}-->
  156. <!-- </if>-->
  157. <if test="parentGuid != null and parentGuid != ''">
  158. and parent_guid = #{parentGuid}
  159. </if>
  160. <if test="deleted != null ">
  161. and deleted = #{deleted}
  162. </if>
  163. <if test="sort != null ">
  164. and sort = #{sort}
  165. </if>
  166. <!-- <if test="location != null ">-->
  167. <!-- and location = #{location}-->
  168. <!-- </if>-->
  169. </where>
  170. </select>
  171. <select id="selectSysOrgById" parameterType="Long"
  172. resultMap="SysOrgResult">
  173. <include refid="selectSysOrgVo"/>
  174. where id = #{id}
  175. </select>
  176. <select id="selectCheckSubOrgIdList" resultType="java.lang.Long">
  177. select id
  178. from sys_org
  179. where path like concat((select path from sys_org where id = #{orgId}), '%')
  180. and deleted = 0
  181. </select>
  182. <select id="findListByOrgType" resultType="java.lang.Long">
  183. select a.id
  184. from sys_org a
  185. where a.type = #{execOrgType}
  186. and a.deleted = 0
  187. and a.is_lock = 0
  188. </select>
  189. <insert id="insertSysOrg" parameterType="com.xunmei.system.api.domain.SysOrg" useGeneratedKeys="true"
  190. keyProperty="id">
  191. insert into sys_org
  192. <trim prefix="(" suffix=")" suffixOverrides=",">
  193. <if test="address != null">
  194. address,
  195. </if>
  196. <if test="code != null">
  197. code,
  198. </if>
  199. <!-- <if test="deviceCount != null">device_count,-->
  200. <!-- </if>-->
  201. <if test="guid != null">
  202. guid,
  203. </if>
  204. <if test="isLock != null">
  205. is_lock,
  206. </if>
  207. <if test="manager != null">
  208. manager,
  209. </if>
  210. <if test="managerPhone != null">
  211. manager_phone,
  212. </if>
  213. <if test="name != null">
  214. name,
  215. </if>
  216. <if test="shortName != null">
  217. short_name,
  218. </if>
  219. <if test="parentId != null">
  220. parent_id,
  221. </if>
  222. <if test="phone != null">
  223. phone,
  224. </if>
  225. <if test="cityCode != null">
  226. city_code,
  227. </if>
  228. <!-- <if test="openYear != null">open_year,-->
  229. <!-- </if>-->
  230. <!-- <if test="fitYear != null">fit_year,-->
  231. <!-- </if>-->
  232. <!-- <if test="floorage != null">floorage,-->
  233. <!-- </if>-->
  234. <!-- <if test="employee != null">employee,-->
  235. <!-- </if>-->
  236. <!-- <if test="isOwnRight != null">is_own_right,-->
  237. <!-- </if>-->
  238. <!-- <if test="isRent != null">is_rent,-->
  239. <!-- </if>-->
  240. <!-- <if test="isOnly != null">is_only,-->
  241. <!-- </if>-->
  242. <!-- <if test="buildYear != null">build_year,-->
  243. <!-- </if>-->
  244. <!-- <if test="placeType != null">place_type,-->
  245. <!-- </if>-->
  246. <!-- <if test="buildHeight != null">build_height,-->
  247. <!-- </if>-->
  248. <!-- <if test="social != null">social,-->
  249. <!-- </if>-->
  250. <!-- <if test="naturalEnvir != null">natural_envir,-->
  251. <!-- </if>-->
  252. <if test="type != null">
  253. type,
  254. </if>
  255. <if test="createTime != null">
  256. create_time,
  257. </if>
  258. <if test="updateBy != null">
  259. update_by,
  260. </if>
  261. <if test="updateTime != null">
  262. update_time,
  263. </if>
  264. <!-- <if test="modifiedId != null">modified_id,-->
  265. <!-- </if>-->
  266. <if test="path != null">
  267. path,
  268. </if>
  269. <!-- <if test="vid != null">vid,-->
  270. <!-- </if>-->
  271. <!-- <if test="level != null">level,-->
  272. <!-- </if>-->
  273. <if test="oid != null">
  274. oid,
  275. </if>
  276. <if test="parentGuid != null">
  277. parent_guid,
  278. </if>
  279. <if test="deleted != null">
  280. deleted,
  281. </if>
  282. <if test="sort != null">
  283. sort,
  284. </if>
  285. <if test="source != null">
  286. source,
  287. </if>
  288. <if test="remark != null">
  289. remark,
  290. </if>
  291. <!-- <if test="location != null">location,-->
  292. <!-- </if>-->
  293. <if test="createBy != null">
  294. create_by,
  295. </if>
  296. <if test="updateBy != null">
  297. update_by,
  298. </if>
  299. <if test="treeParentCode != null">
  300. treeParentCode,
  301. </if>
  302. <if test="treeShowPath != null">
  303. treeShowPath,
  304. </if>
  305. <if test="treeShowParentId != null">
  306. treeShowParentId,
  307. </if>
  308. </trim>
  309. <trim prefix="values (" suffix=")" suffixOverrides=",">
  310. <if test="address != null">
  311. #{address},
  312. </if>
  313. <if test="code != null">
  314. #{code},
  315. </if>
  316. <!-- <if test="deviceCount != null">#{deviceCount},-->
  317. <!-- </if>-->
  318. <if test="guid != null">
  319. #{guid},
  320. </if>
  321. <if test="isLock != null">
  322. #{isLock},
  323. </if>
  324. <if test="manager != null">
  325. #{manager},
  326. </if>
  327. <if test="managerPhone != null">
  328. #{managerPhone},
  329. </if>
  330. <if test="name != null">
  331. #{name},
  332. </if>
  333. <if test="shortName != null">
  334. #{shortName},
  335. </if>
  336. <if test="parentId != null">
  337. #{parentId},
  338. </if>
  339. <if test="phone != null">
  340. #{phone},
  341. </if>
  342. <if test="cityCode != null">
  343. #{cityCode},
  344. </if>
  345. <!-- <if test="openYear != null">#{openYear},-->
  346. <!-- </if>-->
  347. <!-- <if test="fitYear != null">#{fitYear},-->
  348. <!-- </if>-->
  349. <!-- <if test="floorage != null">#{floorage},-->
  350. <!-- </if>-->
  351. <!-- <if test="employee != null">#{employee},-->
  352. <!-- </if>-->
  353. <!-- <if test="isOwnRight != null">#{isOwnRight},-->
  354. <!-- </if>-->
  355. <!-- <if test="isRent != null">#{isRent},-->
  356. <!-- </if>-->
  357. <!-- <if test="isOnly != null">#{isOnly},-->
  358. <!-- </if>-->
  359. <!-- <if test="buildYear != null">#{buildYear},-->
  360. <!-- </if>-->
  361. <!-- <if test="placeType != null">#{placeType},-->
  362. <!-- </if>-->
  363. <!-- <if test="buildHeight != null">#{buildHeight},-->
  364. <!-- </if>-->
  365. <!-- <if test="social != null">#{social},-->
  366. <!-- </if>-->
  367. <!-- <if test="naturalEnvir != null">#{naturalEnvir},-->
  368. <!-- </if>-->
  369. <if test="type != null">
  370. #{type},
  371. </if>
  372. <if test="createTime != null">
  373. #{createTime},
  374. </if>
  375. <if test="updateBy != null">
  376. #{updateBy},
  377. </if>
  378. <if test="updateTime != null">
  379. #{updateTime},
  380. </if>
  381. <!-- <if test="modifiedId != null">#{modifiedId},-->
  382. <!-- </if>-->
  383. <if test="path != null">
  384. #{path},
  385. </if>
  386. <!-- <if test="vid != null">#{vid},-->
  387. <!-- </if>-->
  388. <!-- <if test="level != null">#{level},-->
  389. <!-- </if>-->
  390. <!-- <if test="oid != null">#{oid},-->
  391. <!-- </if>-->
  392. <if test="parentGuid != null">
  393. #{parentGuid},
  394. </if>
  395. <if test="deleted != null">
  396. #{deleted},
  397. </if>
  398. <if test="sort != null">
  399. #{sort},
  400. </if>
  401. <if test="source != null">
  402. #{source},
  403. </if>
  404. <if test="remark != null">
  405. #{remark},
  406. </if>
  407. <!-- <if test="location != null">#{location},-->
  408. <!-- </if>-->
  409. <if test="createBy != null">
  410. #{createBy},
  411. </if>
  412. <if test="updateBy != null">
  413. #{updateBy},
  414. </if>
  415. <if test="treeParentCode != null">
  416. #{treeParentCode},
  417. </if>
  418. <if test="treeShowPath != null">
  419. #{treeShowPath},
  420. </if>
  421. <if test="treeShowParentId != null">
  422. #{treeShowParentId},
  423. </if>
  424. </trim>
  425. </insert>
  426. <update id="updateSysOrg" parameterType="com.xunmei.system.api.domain.SysOrg">
  427. update sys_org
  428. <trim prefix="SET" suffixOverrides=",">
  429. <if test="address != null">
  430. address =
  431. #{address},
  432. </if>
  433. <if test="code != null">
  434. code =
  435. #{code},
  436. </if>
  437. <!-- <if test="deviceCount != null">device_count =-->
  438. <!-- #{deviceCount},-->
  439. <!-- </if>-->
  440. <if test="guid != null">
  441. guid =
  442. #{guid},
  443. </if>
  444. <if test="isLock != null">
  445. is_lock =
  446. #{isLock},
  447. </if>
  448. <if test="manager != null">
  449. manager =
  450. #{manager},
  451. </if>
  452. <if test="managerPhone != null">
  453. manager_phone =
  454. #{managerPhone},
  455. </if>
  456. <if test="name != null">
  457. name =
  458. #{name},
  459. </if>
  460. <if test="shortName != null">
  461. short_name =
  462. #{shortName},
  463. </if>
  464. <if test="parentId != null">
  465. parent_id =
  466. #{parentId},
  467. </if>
  468. <if test="phone != null">
  469. phone =
  470. #{phone},
  471. </if>
  472. <if test="cityCode != null">
  473. city_code =
  474. #{cityCode},
  475. </if>
  476. <!-- <if test="openYear != null">open_year =-->
  477. <!-- #{openYear},-->
  478. <!-- </if>-->
  479. <!-- <if test="fitYear != null">fit_year =-->
  480. <!-- #{fitYear},-->
  481. <!-- </if>-->
  482. <!-- <if test="floorage != null">floorage =-->
  483. <!-- #{floorage},-->
  484. <!-- </if>-->
  485. <!-- <if test="employee != null">employee =-->
  486. <!-- #{employee},-->
  487. <!-- </if>-->
  488. <!-- <if test="isOwnRight != null">is_own_right =-->
  489. <!-- #{isOwnRight},-->
  490. <!-- </if>-->
  491. <!-- <if test="isRent != null">is_rent =-->
  492. <!-- #{isRent},-->
  493. <!-- </if>-->
  494. <!-- <if test="isOnly != null">is_only =-->
  495. <!-- #{isOnly},-->
  496. <!-- </if>-->
  497. <!-- <if test="buildYear != null">build_year =-->
  498. <!-- #{buildYear},-->
  499. <!-- </if>-->
  500. <!-- <if test="placeType != null">place_type =-->
  501. <!-- #{placeType},-->
  502. <!-- </if>-->
  503. <!-- <if test="buildHeight != null">build_height =-->
  504. <!-- #{buildHeight},-->
  505. <!-- </if>-->
  506. <!-- <if test="social != null">social =-->
  507. <!-- #{social},-->
  508. <!-- </if>-->
  509. <!-- <if test="naturalEnvir != null">natural_envir =-->
  510. <!-- #{naturalEnvir},-->
  511. <!-- </if>-->
  512. <if test="type != null">
  513. type =
  514. #{type},
  515. </if>
  516. <if test="createTime != null">
  517. create_time =
  518. #{createTime},
  519. </if>
  520. <if test="updateBy != null">
  521. update_by =
  522. #{updateBy},
  523. </if>
  524. <if test="updateTime != null">
  525. update_time =
  526. #{updateTime},
  527. </if>
  528. <!-- <if test="modifiedId != null">modified_id =-->
  529. <!-- #{modifiedId},-->
  530. <!-- </if>-->
  531. <if test="path != null">
  532. path =
  533. #{path},
  534. </if>
  535. <!-- <if test="vid != null">vid =-->
  536. <!-- #{vid},-->
  537. <!-- </if>-->
  538. <!-- <if test="level != null">level =-->
  539. <!-- #{level},-->
  540. <!-- </if>-->
  541. <!-- <if test="oid != null">oid =-->
  542. <!-- #{oid},-->
  543. <!-- </if>-->
  544. <if test="parentGuid != null">
  545. parent_guid =
  546. #{parentGuid},
  547. </if>
  548. <if test="deleted != null">
  549. deleted =
  550. #{deleted},
  551. </if>
  552. <if test="sort != null">
  553. sort =
  554. #{sort},
  555. </if>
  556. <if test="source != null">
  557. source =
  558. #{source},
  559. </if>
  560. <if test="remark != null">
  561. remark =
  562. #{remark},
  563. </if>
  564. <!-- <if test="location != null">location =-->
  565. <!-- #{location},-->
  566. <!-- </if>-->
  567. <if test="createBy != null">
  568. create_by =
  569. #{createBy},
  570. </if>
  571. <if test="updateBy != null">
  572. update_by =
  573. #{updateBy},
  574. </if>
  575. <if test="treeParentCode != null">
  576. tree_parent_code= #{treeParentCode},
  577. </if>
  578. <if test="treeShowPath != null">
  579. tree_show_path=#{treeShowPath},
  580. </if>
  581. <if test="treeShowParentId != null">
  582. tree_show_parentId=#{treeShowParentId},
  583. </if>
  584. </trim>
  585. where id = #{id}
  586. </update>
  587. <delete id="deleteSysOrgById" parameterType="Long">
  588. delete
  589. from sys_org
  590. where id = #{id}
  591. </delete>
  592. <delete id="deleteSysOrgByIds" parameterType="String">
  593. delete from sys_org where id in
  594. <foreach item="id" collection="array" open="(" separator="," close=")">
  595. #{id}
  596. </foreach>
  597. </delete>
  598. <select id="selectSysOrgByUserId" resultType="com.xunmei.system.api.domain.SysOrg">
  599. select so.*
  600. from sys_org so
  601. inner join sys_user suo on so.id = suo.org_id
  602. where suo.id = #{userId}
  603. </select>
  604. <select id="getParentName" resultType="com.xunmei.common.core.vo.IdNameVo">
  605. select so.id,so.short_name as name,p.short_name as extra
  606. from sys_org so
  607. left join sys_org p on so.parent_id=p.id and p.deleted=0
  608. where so.id in
  609. <foreach collection="ids" item="id" separator="," open="(" close=")">
  610. #{id}
  611. </foreach>
  612. and so.deleted=0
  613. </select>
  614. <select id="selectSysOrgVoByUserId" resultType="com.xunmei.system.api.vo.SysOrgVO">
  615. select so.id as id, so.name as name, so.path as path, so.parent_id as parentId
  616. from sys_org so
  617. inner join sys_user suo on so.id = suo.org_id
  618. where suo.id = #{userId}
  619. </select>
  620. <select id="selectSysOrgVOList" resultType="com.xunmei.system.api.vo.SysOrgVO">
  621. SELECT id,
  622. `name`,
  623. if(short_name is null,`name` ,short_name) as short_name,
  624. code,
  625. path,
  626. parent_id,
  627. type,
  628. tree_show_parent_id,
  629. tree_show_path,
  630. if(sort is null,0,sort) as sort
  631. FROM sys_org
  632. WHERE deleted = 0
  633. ORDER BY isnull(sort),sort, path
  634. </select>
  635. <select id="selectOrgList" resultType="com.xunmei.system.api.domain.SysOrg">
  636. select o.*,e.weather_area_code as weather_city_code from sys_org o
  637. left join sys_org_extend e on o.id = e.org_id
  638. WHERE deleted = 0
  639. <if test=" org.isLock != null">
  640. and o.is_lock =#{org.isLock}
  641. </if>
  642. <if test=" org.type != null and org.type !=''">
  643. and o.type =#{org.type}
  644. </if>
  645. <if test=" org.name != null and org.name !=''">
  646. and (o.name like concat(concat('%',#{org.name}),'%') or o.short_name like concat(concat('%',#{org.name}),'%'))
  647. </if>
  648. <if test=" org.code != null and org.code !=''">
  649. and o.code like concat(concat('%',#{org.code}),'%')
  650. </if>
  651. <!-- <if test=" org.parentId != null and org.parentId !=''">-->
  652. <!-- and o.parent_id =#{org.parentId}-->
  653. <!-- </if>-->
  654. <if test=" org.checkSub != null and org.checkSub == true">
  655. and o.path like concat(concat('%',#{org.path}),'%')
  656. </if>
  657. <if test=" org.checkSub != null and org.checkSub == false">
  658. and o.path like concat('%',#{org.path})
  659. </if>
  660. and o.name != '机关'
  661. ORDER BY isnull(o.sort),o.sort, o.path
  662. </select>
  663. <select id="getOrgIdByTaskId" resultType="java.lang.Long">
  664. SELECT org_id
  665. FROM core_monitoring_retrieval_task cmrt
  666. WHERE id = #{taskId}
  667. </select>
  668. <select id="selectOrgTypeByIdList" resultType="java.lang.Long">
  669. select distinct type
  670. from sys_org
  671. where id in
  672. <foreach collection="orgIdList" item="item" open="(" separator="," close=")">
  673. #{item}
  674. </foreach>
  675. </select>
  676. <select id="findByOrgTypeAndParent" resultType="com.xunmei.system.api.domain.SysOrg">
  677. select c.* from sys_org c where c.type = #{orgType} and c.path like concat('%',#{path}, '%') and deleted=0
  678. </select>
  679. <select id="selectByShortName" resultType="com.xunmei.system.api.domain.SysOrg">
  680. SELECT * FROM sys_org WHERE short_name=#{name} AND deleted=0
  681. </select>
  682. <select id="findByOrgTypesAndParent" resultType="com.xunmei.system.api.domain.SysOrg">
  683. select c.* from sys_org c where c.path like concat('%',#{path}, '%') and deleted=0
  684. and
  685. c.type in
  686. <foreach collection="types" item="type" separator="," open="(" close=")">
  687. #{type}
  688. </foreach>
  689. </select>
  690. <select id="selectNetworkNumberByPath" resultType="java.lang.Integer">
  691. SELECT COUNT(1) FROM sys_org WHERE path LIKE concat( #{orgPath}, '%') AND type=4 AND deleted=0
  692. </select>
  693. <select id="complianceStatus" resultType="com.xunmei.system.util.OrgPhysicalDefenseConstructionExport">
  694. SELECT
  695. IFNULL( SUM( IF ( a.standard IN ( 1, 2 ), 1, 0 )), 0 ) AS reachNumber,
  696. IFNULL( SUM( IF ( a.standard = 2, 1, 0 )), 0 ) AS oldReachNumber,
  697. IFNULL( SUM( IF ( a.standard = 1, 1, 0 )), 0 ) AS newReachNumber,
  698. IFNULL(
  699. CONCAT(
  700. ROUND( SUM( IF ( a.standard IN ( 1, 2 ), 1, 0 ))/ COUNT( b.id )* 100, 2 ),
  701. '%'
  702. ),
  703. '0%'
  704. ) AS reachRate
  705. FROM
  706. sys_org_physical_defense_construction a
  707. LEFT JOIN sys_org b ON a.org_id = b.id
  708. WHERE
  709. b.path LIKE concat(#{orgPath}, '%')
  710. </select>
  711. <select id="rectificationStatus" resultType="java.lang.Integer">
  712. SELECT
  713. IFNULL(SUM(IF(a.standard=1,1,0)),0)
  714. FROM
  715. sys_org_physical_defense_construction a LEFT JOIN sys_org b ON a.org_id=b.id
  716. WHERE
  717. a.date_of_compliance LIKE concat(#{year}, '%') AND b.path LIKE concat(#{orgPath}, '%')
  718. </select>
  719. <select id="oldRectificationStatus" resultType="java.lang.Integer">
  720. SELECT
  721. COUNT( DISTINCT a.org_id )
  722. FROM
  723. sys_org_physical_defense_construction a
  724. INNER JOIN sys_org b ON a.org_id = b.id
  725. WHERE
  726. a.org_id IN (
  727. SELECT
  728. org_id
  729. FROM
  730. sys_org_physical_defense_construction
  731. GROUP BY
  732. org_id
  733. HAVING
  734. (
  735. IF
  736. ( LOCATE( 1, GROUP_CONCAT( standard ))> 0, 1, 0 )+
  737. IF
  738. ( LOCATE( 2, GROUP_CONCAT( standard ))> 0, 1, 0 ))= 2
  739. AND date_of_compliance LIKE concat(#{year}, '%')
  740. )AND b.path LIKE concat(#{orgPath}, '%')
  741. </select>
  742. <select id="noRectificationStatus" resultType="java.lang.Integer">
  743. SELECT
  744. COUNT( DISTINCT org_id )
  745. FROM
  746. sys_org_physical_defense_construction a LEFT JOIN sys_org b ON a.org_id=b.id
  747. WHERE
  748. org_id IN (
  749. SELECT
  750. GROUP_CONCAT( DISTINCT org_id )
  751. FROM
  752. sys_org_physical_defense_construction
  753. GROUP BY
  754. org_id
  755. HAVING
  756. (
  757. IF
  758. ( LOCATE( 1, GROUP_CONCAT( standard ))> 0, 1, 0 )+
  759. IF
  760. ( LOCATE( 3, GROUP_CONCAT( standard ))> 0, 1, 0 ))= 2
  761. AND date_of_compliance LIKE concat(#{year}, '%')
  762. ) AND b.path LIKE concat(#{orgPath}, '%')
  763. </select>
  764. <select id="selectConstructionDetail" resultType="com.xunmei.system.util.ConstructionDetailExport">
  765. SELECT
  766. a.org_id AS orgId,
  767. IFNULL( b.ownership, 0 ) AS ownership,
  768. IF
  769. (
  770. IF
  771. ( LOCATE( 1, GROUP_CONCAT( a.standard ))> 0, 1, 0 )+
  772. IF
  773. ( LOCATE( 2, GROUP_CONCAT( a.standard ))> 0, 1, 0 )>= 1,
  774. 1,
  775. 0
  776. ) AS complianceStatus,
  777. a.date_of_compliance AS complianceDate,
  778. IF
  779. (
  780. IF
  781. ( LOCATE( 1, GROUP_CONCAT( a.standard ))> 0, 1, 0 )+
  782. IF
  783. ( LOCATE( 2, GROUP_CONCAT( a.standard ))> 0, 1, 0 )>= 1,
  784. NULL,
  785. a.reason
  786. ) AS reason,
  787. a.date_of_complete AS completeDate
  788. FROM
  789. sys_org_physical_defense_construction a
  790. LEFT JOIN sys_org_extend b ON a.org_id = b.org_id LEFT JOIN sys_org c ON c.id=b.org_id
  791. WHERE c.type=4 and c.path like concat(#{orgPath}, '%')
  792. GROUP BY
  793. a.org_id
  794. </select>
  795. <select id="getReachNumber" resultType="java.lang.Integer">
  796. SELECT
  797. IFNULL( SUM( IF ( a.standard IN ( 1, 2 ), 1, 0 )), 0 )
  798. FROM
  799. sys_org_physical_defense_construction a
  800. LEFT JOIN sys_org b ON a.org_id = b.id
  801. WHERE b.type=4 and b.path LIKE concat(#{orgPath}, '%')
  802. </select>
  803. <select id="getOwnership" resultType="java.lang.Integer">
  804. SELECT
  805. IFNULL( SUM( IF ( a.ownership = 2, 1, 0 )), 0 )
  806. FROM
  807. sys_org_extend a
  808. LEFT JOIN sys_org b ON a.org_id = b.id
  809. WHERE b.type=4 and b.path LIKE concat(#{orgPath}, '%')
  810. </select>
  811. <select id="getOutside" resultType="java.lang.Integer">
  812. SELECT
  813. IFNULL( SUM( IF ( a.outside_area = 1, 1, 0 )), 0 )
  814. FROM
  815. sys_org_extend a
  816. LEFT JOIN sys_org b ON a.org_id = b.id
  817. where
  818. b.path LIKE concat(#{orgPath}, '%')
  819. </select>
  820. <select id="getLibrary" resultType="java.util.Map">
  821. SELECT
  822. COUNT(a.business_library_type ) as total,
  823. sum(IF(a.business_library_type=1,1,0)) AS one,
  824. SUM(IF(a.business_library_type=2,1,0)) as two,
  825. SUM(IF(a.business_library_type=3,1,0)) AS three,
  826. SUM(IF(a.business_library_type=4,1,0)) AS four
  827. FROM
  828. sys_org_extend a
  829. LEFT JOIN sys_org b ON a.org_id = b.id
  830. where
  831. b.path LIKE concat(#{orgPath}, '%')
  832. </select>
  833. <select id="getCollectLibrary" resultType="java.lang.Integer">
  834. SELECT
  835. SUM(
  836. IF
  837. ( a.safe_box = 1, 1, 0 ))
  838. FROM
  839. sys_org_extend a
  840. LEFT JOIN sys_org b ON a.org_id = b.id
  841. WHERE
  842. b.path LIKE concat(#{orgPath}, '%')
  843. </select>
  844. <select id="getOnLine" resultType="java.util.Map">
  845. SELECT
  846. SUM(
  847. IF
  848. ( a.type = 3, 1, 0 )) AS onLineTotal,
  849. SUM(
  850. IF
  851. ( a.type = 3 AND a.standard =1, 1, 0 )) AS onLineReachNumber
  852. FROM
  853. sys_org_physical_defense_construction a
  854. LEFT JOIN sys_org b ON a.org_id = b.id
  855. WHERE
  856. b.path LIKE concat(#{orgPath}, '%')
  857. </select>
  858. <select id="getDeparture" resultType="java.util.Map">
  859. SELECT
  860. SUM(
  861. IF
  862. ( a.type = 4, 1, 0 )) AS departureTotal,
  863. SUM(
  864. IF
  865. ( a.type = 4 AND a.standard = 1, 1, 0 )) AS departureReachNumber
  866. FROM
  867. sys_org_physical_defense_construction a
  868. LEFT JOIN sys_org b ON a.org_id = b.id
  869. WHERE
  870. b.path LIKE concat(#{orgPath}, '%')
  871. </select>
  872. <select id="getSelfEquipment" resultType="java.util.Map">
  873. SELECT
  874. SUM( a.lobby_equipment ) AS onLineLobbyImplement,
  875. SUM( a.wall_penetrating_equipment ) AS onLineThroughWalls,
  876. SUM( a.detached_lobby_equipment ) AS departureLobbyImplement,
  877. SUM( a.detached_wall_penetrating_equipment ) AS departureThroughWalls,
  878. SUM( a.lobby_equipment ) + SUM( a.wall_penetrating_equipment ) + SUM( a.detached_lobby_equipment ) + SUM( a.detached_wall_penetrating_equipment ) AS selfServiceDevicesTotal
  879. FROM
  880. sys_org_extend a
  881. LEFT JOIN sys_org b ON a.org_id = b.id
  882. WHERE
  883. b.path LIKE concat(#{orgPath}, '%')
  884. </select>
  885. <select id="getCenterConstruction" resultType="java.util.Map">
  886. SELECT
  887. IF
  888. ( a.construction_time IS NULL, '', SUBSTR( a.construction_time, 1, 4 ) ) AS centerConstructionTime,
  889. IF
  890. ( a.last_update_time IS NULL, '', SUBSTR( a.last_update_time, 1, 4 ) ) AS transformTime,
  891. a.platform_brand AS brand
  892. FROM
  893. sys_org_extend a
  894. LEFT JOIN sys_org b ON a.org_id = b.id
  895. WHERE b.id=#{orgId}
  896. </select>
  897. <select id="getCamera" resultType="java.util.Map">
  898. SELECT
  899. COUNT( 1 ) AS cameraTotal,
  900. SUM(
  901. IF
  902. ( definition = 1, 1, 0 )) AS definitionNumber
  903. FROM
  904. sys_device
  905. WHERE
  906. del_flag=0 AND
  907. device_type =2 AND org_path LIKE concat(#{orgPath}, '%')
  908. </select>
  909. <select id="getRemote" resultType="java.util.Map">
  910. SELECT
  911. SUM( a.cash_adding_room ) AS cashAddingRoom,
  912. SUM( a.remote_count ) AS remoteCount
  913. FROM
  914. sys_org_extend a
  915. LEFT JOIN sys_org b ON a.org_id = b.id
  916. where org_path LIKE concat(#{orgPath}, '%')
  917. </select>
  918. <select id="getDuty" resultType="java.util.Map">
  919. SELECT
  920. SUM(
  921. IF
  922. ( duty_mode = 2, 1, 0 )) AS localDutyNetworkNumber,
  923. SUM(
  924. IF
  925. ( duty_mode = 1, 1, 0 )) AS remoteDutyNetworkNumber
  926. FROM
  927. sys_org_extend a
  928. LEFT JOIN sys_org b ON a.org_id = b.id
  929. where org_path LIKE concat(#{orgPath}, '%')
  930. </select>
  931. </mapper>