WmDaAgentMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. ~
  4. ~ Copyright (c) 2018-2025, hnqz All rights reserved.
  5. ~
  6. ~ Redistribution and use in source and binary forms, with or without
  7. ~ modification, are permitted provided that the following conditions are met:
  8. ~
  9. ~ Redistributions of source code must retain the above copyright notice,
  10. ~ this list of conditions and the following disclaimer.
  11. ~ Redistributions in binary form must reproduce the above copyright
  12. ~ notice, this list of conditions and the following disclaimer in the
  13. ~ documentation and/or other materials provided with the distribution.
  14. ~ Neither the name of the pig4cloud.com developer nor the names of its
  15. ~ contributors may be used to endorse or promote products derived from
  16. ~ this software without specific prior written permission.
  17. ~ Author: hnqz
  18. ~
  19. -->
  20. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  21. <mapper namespace="com.qunzhixinxi.hnqz.admin.mapper.WmDaAgentMapper">
  22. <resultMap id="wmDaAgentMap" type="com.qunzhixinxi.hnqz.admin.entity.WmDaAgent">
  23. <id property="id" column="id"/>
  24. <result property="gsmc" column="gsmc"/>
  25. <result property="yyzz" column="yyzz"/>
  26. <result property="sbjnzm" column="sbjnzm"/>
  27. <result property="frsfzzmZm" column="frsfzzm_zm"/>
  28. <result property="frsfzzmBm" column="frsfzzm_bm"/>
  29. <result property="frsfzzmSc" column="frsfzzm_sc"/>
  30. <result property="zjType" column="zj_type"/>
  31. <result property="zjNumber" column="zj_number"/>
  32. <result property="jsAccount" column="js_account"/>
  33. <result property="isExamine" column="is_examine"/>
  34. <result property="extDrugEnt" column="ext_drug_ent"/>
  35. <result property="temp1" column="temp1"/>
  36. <result property="temp2" column="temp2"/>
  37. <result property="deptId" column="dept_id"/>
  38. <result property="delFlag" column="del_flag"/>
  39. <result property="enableFlag" column="enable_flag"/>
  40. <result property="tenantId" column="tenant_id"/>
  41. <result property="createTime" column="create_time"/>
  42. <result property="createUser" column="create_user"/>
  43. <result property="updateTime" column="update_time"/>
  44. <result property="updateUser" column="update_user"/>
  45. <result property="drugEntId" column="drug_ent_id"/>
  46. <result property="pgqx" column="pgqx"/>
  47. <result property="qylx" column="qylx"/>
  48. <result property="management" column="management"/>
  49. </resultMap>
  50. <insert id="insert1" parameterType="com.qunzhixinxi.hnqz.admin.entity.WmDaAgent" >
  51. insert into wm_da_agent (gsmc, yyzz,
  52. sbjnzm, frsfzzm_zm, frsfzzm_bm,
  53. frsfzzm_sc, zj_type, zj_number,
  54. js_account, is_examine, ext_drug_ent,
  55. temp1, temp2, dept_id,
  56. del_flag, enable_flag, tenant_id,
  57. create_time, create_user, update_time,
  58. update_user, drug_ent_id, pgqx, qylx
  59. )
  60. values (#{gsmc,jdbcType=VARCHAR}, #{yyzz,jdbcType=VARCHAR},
  61. #{sbjnzm,jdbcType=VARCHAR}, #{frsfzzmZm,jdbcType=VARCHAR}, #{frsfzzmBm,jdbcType=VARCHAR},
  62. #{frsfzzmSc,jdbcType=VARCHAR}, #{zjType,jdbcType=VARCHAR}, #{zjNumber,jdbcType=VARCHAR},
  63. #{jsAccount,jdbcType=VARCHAR}, #{isExamine,jdbcType=VARCHAR}, #{extDrugEnt,jdbcType=VARCHAR},
  64. #{temp1,jdbcType=VARCHAR}, #{temp2,jdbcType=VARCHAR}, #{deptId,jdbcType=VARCHAR},
  65. #{delFlag,jdbcType=VARCHAR}, #{enableFlag,jdbcType=VARCHAR}, #{tenantId,jdbcType=BIGINT},#{createTime,jdbcType=VARCHAR},
  66. #{createUser,jdbcType=BIGINT}, #{updateTime,jdbcType=VARCHAR}, #{updateUser,jdbcType=VARCHAR},
  67. #{drugEntId,jdbcType=VARCHAR}, #{pgqx,jdbcType=VARCHAR}, #{qylx,jdbcType=VARCHAR}
  68. )
  69. </insert>
  70. <!-- 分页查询派工企业 -->
  71. <select id="selectWmManagementPage" resultMap="wmDaAgentMap">
  72. SELECT
  73. a.*, d.dept_permissions, d.level as dept_level
  74. FROM wm_da_agent a
  75. LEFT JOIN sys_dept d ON d.dept_id = a.dept_id
  76. <where>
  77. AND d.dept_id IS NOT NULL
  78. AND (d.level = 3 OR d.level = 4 OR d.level = 5)
  79. <if test="query.gsmc != null and query.gsmc !=''">
  80. AND gsmc LIKE CONCAT('%',#{query.gsmc},'%')
  81. </if>
  82. <if test="query.zjNumber != null and query.zjNumber !=''">
  83. AND zj_number LIKE CONCAT('%',#{query.zjNumber},'%')
  84. </if>
  85. <if test="query.pgqx != null and query.pgqx!=''">
  86. AND pgqx = #{query.pgqx,jdbcType=VARCHAR}
  87. </if>
  88. <if test="query.updateTime != null and query.updateTime !=''">
  89. AND update_time = #{query.updateTime,jdbcType=VARCHAR}
  90. </if>
  91. <if test="query.createTime != null and query.createTime!='' ">
  92. AND create_time = #{query.createTime,jdbcType=VARCHAR}
  93. </if>
  94. <if test="query.yyzz != null and query.yyzz!='' ">
  95. AND yyzz = #{query.yyzz,jdbcType=VARCHAR}
  96. </if>
  97. <if test="query.sbjnzm != null and query.sbjnzm!='' ">
  98. AND sbjnzm = #{query.sbjnzm,jdbcType=VARCHAR}
  99. </if>
  100. <if test="query.frsfzzmZm != null and query.frsfzzmZm!='' ">
  101. AND frsfzzm_zm = #{query.frsfzzmZm,jdbcType=VARCHAR}
  102. </if>
  103. <if test="query.frsfzzmBm != null and query.frsfzzmBm!='' ">
  104. AND frsfzzm_bm = #{query.frsfzzmBm,jdbcType=VARCHAR}
  105. </if>
  106. <if test="query.frsfzzmSc != null and query.frsfzzmSc!=''">
  107. AND frsfzzm_sc = #{query.frsfzzmSc,jdbcType=VARCHAR}
  108. </if>
  109. <if test="query.extDrugEnt != null and query.extDrugEnt!=''">
  110. AND ext_drug_ent = #{query.extDrugEnt,jdbcType=VARCHAR}
  111. </if>
  112. <if test="query.qylx != null and query.qylx!=''">
  113. AND qylx = #{query.qylx,jdbcType=VARCHAR}
  114. </if>
  115. </where>
  116. ORDER BY id DESC
  117. </select>
  118. <select id="selectWmManagementList" resultMap="wmDaAgentMap">
  119. select
  120. *
  121. from wm_da_agent where 1=1
  122. <if test="query.gsmc != null and query.gsmc !=''">
  123. AND gsmc like CONCAT('%',#{query.gsmc},'%')
  124. </if>
  125. <if test="query.zjNumber != null and query.zjNumber !=''">
  126. AND zj_number like CONCAT('%',#{query.zjNumber},'%')
  127. </if>
  128. <if test="query.pgqx != null and query.pgqx!=''">
  129. AND pgqx = #{query.pgqx,jdbcType=VARCHAR}
  130. </if>
  131. <if test="query.updateTime != null and query.updateTime !=''">
  132. AND update_time = #{query.updateTime,jdbcType=VARCHAR}
  133. </if>
  134. <if test="query.createTime != null and query.createTime!='' ">
  135. AND create_time = #{query.createTime,jdbcType=VARCHAR}
  136. </if>
  137. <if test="query.yyzz != null and query.yyzz!='' ">
  138. AND yyzz = #{query.yyzz,jdbcType=VARCHAR}
  139. </if>
  140. <if test="query.sbjnzm != null and query.sbjnzm!='' ">
  141. AND sbjnzm = #{query.sbjnzm,jdbcType=VARCHAR}
  142. </if>
  143. <if test="query.frsfzzmZm != null and query.frsfzzmZm!='' ">
  144. AND frsfzzm_zm = #{query.frsfzzmZm,jdbcType=VARCHAR}
  145. </if>
  146. <if test="query.frsfzzmBm != null and query.frsfzzmBm!='' ">
  147. AND frsfzzm_bm = #{query.frsfzzmBm,jdbcType=VARCHAR}
  148. </if>
  149. <if test="query.frsfzzmSc != null and query.frsfzzmSc!=''">
  150. AND frsfzzm_sc = #{query.frsfzzmSc,jdbcType=VARCHAR}
  151. </if>
  152. <if test="query.extDrugEnt != null and query.extDrugEnt!=''">
  153. AND ext_drug_ent = #{query.extDrugEnt,jdbcType=VARCHAR}
  154. </if>
  155. <if test="query.qylx != null and query.qylx!=''">
  156. AND qylx = #{query.qylx,jdbcType=VARCHAR}
  157. </if>
  158. order by id desc
  159. </select>
  160. <select id="selectExtDrugEntList" resultMap="wmDaAgentMap">
  161. select
  162. ext_drug_ent
  163. from wm_da_agent
  164. where
  165. gsmc = #{query.gsmc,jdbcType=VARCHAR}
  166. </select>
  167. <select id="selectByGsmcList" resultMap="wmDaAgentMap">
  168. select
  169. *
  170. from wm_da_agent
  171. where
  172. gsmc = #{query.gsmc,jdbcType=VARCHAR}
  173. </select>
  174. <select id="selectByGsmc" resultMap="wmDaAgentMap">
  175. select
  176. *
  177. from wm_da_agent
  178. where
  179. gsmc = #{query.gsmc,jdbcType=VARCHAR}
  180. </select>
  181. <select id="selectDeptId" resultMap="wmDaAgentMap">
  182. select
  183. a.*, d.dept_permissions
  184. from wm_da_agent a
  185. left join sys_dept d
  186. on a.dept_id = d.dept_id
  187. where
  188. a.dept_id = #{deptId,jdbcType=VARCHAR}
  189. </select>
  190. <select id="selectDeptId1" resultType="java.util.HashMap">
  191. select
  192. cast(id as char) as id,gsmc as name
  193. from wm_da_agent
  194. where
  195. dept_id = #{deptId,jdbcType=VARCHAR}
  196. </select>
  197. <select id="selectExtDrugEnt" resultMap="wmDaAgentMap">
  198. select
  199. *
  200. from wm_da_agent
  201. where
  202. ext_drug_ent = #{extDrugEnt,jdbcType=VARCHAR}
  203. </select>
  204. <select id="selectByDeptId" resultMap="wmDaAgentMap" parameterType="java.lang.String">
  205. select
  206. *
  207. from wm_da_agent
  208. where dept_id = #{deptId,jdbcType=VARCHAR}
  209. </select>
  210. <select id="selectByDeptIds" resultMap="wmDaAgentMap" parameterType="java.lang.Integer">
  211. select
  212. *
  213. from wm_da_agent
  214. where dept_id = #{deptId,jdbcType=VARCHAR}
  215. </select>
  216. <select id="selectByDrugIds" resultMap="wmDaAgentMap" parameterType="java.util.HashMap">
  217. select d.*
  218. from wm_da_agent d
  219. left join wm_relation r on r.down_id=d.id
  220. where r.up_id = #{upId,jdbcType=INTEGER}
  221. UNION
  222. select * from wm_da_agent where id= #{Id,jdbcType=INTEGER}
  223. </select>
  224. <select id="selectByDrugId" resultMap="wmDaAgentMap" parameterType="java.util.HashMap">
  225. select d.id,d.gsmc
  226. from wm_da_agent d
  227. left join wm_relation r on r.down_id=d.id
  228. left join wm_da_drug_ent o on r.up_id=o.id
  229. where r.up_id = #{upId,jdbcType=INTEGER}
  230. UNION
  231. select id,entname from wm_da_drug_ent where id= #{Id,jdbcType=INTEGER}
  232. </select>
  233. <select id="selectByRelationId" resultMap="wmDaAgentMap" parameterType="java.lang.Integer">
  234. select *
  235. from
  236. wm_da_agent
  237. where id= #{Id,jdbcType=INTEGER}
  238. </select>
  239. <select id="selectByRelationIds" resultMap="wmDaAgentMap" parameterType="java.util.HashMap">
  240. select d.*
  241. from wm_da_agent d
  242. left join wm_relation r on r.down_id=d.dept_id
  243. where r.up_id = #{upId,jdbcType=INTEGER}
  244. </select>
  245. <select id="selectEntNameByDrugIds" resultMap="wmDaAgentMap" parameterType="java.util.HashMap">
  246. select d.id,d.entname
  247. from wm_da_drug_ent d
  248. left join wm_relation r on r.down_id=d.id
  249. left join wm_da_drug_ent o on r.up_id=o.id
  250. where r.up_id = #{upId,jdbcType=INTEGER}
  251. UNION
  252. select id,gsmc from wm_da_agent where id= #{Id,jdbcType=INTEGER}
  253. </select>
  254. <select id="selectByUserDeptId" resultMap="wmDaAgentMap" parameterType="java.lang.Integer">
  255. select
  256. *
  257. from wm_da_agent
  258. where dept_id = #{deptId,jdbcType=VARCHAR}
  259. </select>
  260. <select id="selectWmDaDrugEntByDeptIds" resultMap="wmDaAgentMap" parameterType="java.util.HashMap">
  261. select d.*
  262. from wm_da_agent d
  263. left join wm_relation r on r.down_id=d.dept_id
  264. where r.up_id = #{upId,jdbcType=INTEGER}
  265. UNION
  266. select * from wm_da_agent where dept_id= #{deptId,jdbcType=VARCHAR}
  267. </select>
  268. <select id="selectWmDaDrugEntByDeptId" resultMap="wmDaAgentMap" parameterType="java.util.HashMap">
  269. select d.id,d.gsmc
  270. from wm_da_agent d
  271. left join wm_relation r on r.down_id=d.dept_id
  272. left join wm_da_drug_ent o on r.up_id=o.dept_id
  273. where r.up_id = #{upId,jdbcType=INTEGER}
  274. UNION
  275. select id,entname from wm_da_drug_ent where dept_id= #{deptId,jdbcType=INTEGER}
  276. </select>
  277. <select id="selectWmDaAgentByRelationId" resultMap="wmDaAgentMap" parameterType="java.lang.Integer">
  278. select *
  279. from
  280. wm_da_agent
  281. where dept_id= #{deptId,jdbcType=INTEGER}
  282. </select>
  283. <select id="selectWmDaAgentByRelationIds" resultMap="wmDaAgentMap" parameterType="java.util.HashMap">
  284. select d.*
  285. from wm_da_agent d
  286. left join wm_relation r on r.down_id=d.dept_id
  287. where r.up_id = #{upId,jdbcType=INTEGER}
  288. </select>
  289. <select id="selectWmDaAgentByDeptId" resultMap="wmDaAgentMap" parameterType="java.util.HashMap">
  290. select d.id,d.gsmc,d.enable_flag
  291. from wm_da_agent d
  292. left join wm_relation r on r.down_id=d.dept_id
  293. left join wm_da_drug_ent o on r.up_id=o.dept_id
  294. where r.up_id = #{upId,jdbcType=INTEGER}
  295. UNION
  296. select id,entname,enable_flag from wm_da_drug_ent where dept_id= #{deptId,jdbcType=INTEGER}
  297. </select>
  298. <select id="selectWmDaAgentByDeptIds" resultMap="wmDaAgentMap" parameterType="java.lang.String">
  299. select *
  300. from
  301. wm_da_agent
  302. where dept_id= #{deptId,jdbcType=VARCHAR}
  303. </select>
  304. <!-- 根据sys_dept表的level字段查询 -->
  305. <select id="listAgentByDeptLevel" resultMap="wmDaAgentMap">
  306. SELECT a.*
  307. FROM wm_da_agent a
  308. LEFT JOIN
  309. sys_dept d ON d.dept_id = a.dept_id
  310. WHERE a.del_flag = 0
  311. AND a.enable_flag = 0
  312. AND d.level = #{deptLevel}
  313. </select>
  314. <!-- 根据deptRelation查询 -->
  315. <select id="listAgentByDeptRelation" resultMap="wmDaAgentMap">
  316. SELECT
  317. *
  318. FROM
  319. wm_da_agent a
  320. LEFT JOIN sys_dept_relation r ON r.descendant = a.dept_id
  321. WHERE
  322. r.ancestor = #{deptId, jdbcType=INTEGER}
  323. </select>
  324. </mapper>