WmDaAgentMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  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 distinct
  73. a.*, d.dept_permissions, d.level as dept_level, d.financial_review_type
  74. FROM wm_da_agent a
  75. LEFT JOIN sys_dept d ON d.dept_id = a.dept_id
  76. <if test="query.csmUserIdList != null and query.csmUserIdList.size() > 0">
  77. left join sys_dept_csm dc on dc.dept_id = a.dept_id
  78. </if>
  79. <where>
  80. AND d.dept_id IS NOT NULL
  81. AND (d.level = 3 OR d.level = 4 OR d.level = 5)
  82. <if test="query.gsmc != null and query.gsmc !=''">
  83. AND gsmc LIKE CONCAT('%',#{query.gsmc},'%')
  84. </if>
  85. <if test="query.zjNumber != null and query.zjNumber !=''">
  86. AND zj_number LIKE CONCAT('%',#{query.zjNumber},'%')
  87. </if>
  88. <if test="query.pgqx != null and query.pgqx!=''">
  89. AND pgqx = #{query.pgqx,jdbcType=VARCHAR}
  90. </if>
  91. <if test="query.updateTime != null and query.updateTime !=''">
  92. AND update_time = #{query.updateTime,jdbcType=VARCHAR}
  93. </if>
  94. <if test="query.createTime != null and query.createTime!='' ">
  95. AND create_time = #{query.createTime,jdbcType=VARCHAR}
  96. </if>
  97. <if test="query.yyzz != null and query.yyzz!='' ">
  98. AND yyzz = #{query.yyzz,jdbcType=VARCHAR}
  99. </if>
  100. <if test="query.sbjnzm != null and query.sbjnzm!='' ">
  101. AND sbjnzm = #{query.sbjnzm,jdbcType=VARCHAR}
  102. </if>
  103. <if test="query.frsfzzmZm != null and query.frsfzzmZm!='' ">
  104. AND frsfzzm_zm = #{query.frsfzzmZm,jdbcType=VARCHAR}
  105. </if>
  106. <if test="query.frsfzzmBm != null and query.frsfzzmBm!='' ">
  107. AND frsfzzm_bm = #{query.frsfzzmBm,jdbcType=VARCHAR}
  108. </if>
  109. <if test="query.frsfzzmSc != null and query.frsfzzmSc!=''">
  110. AND frsfzzm_sc = #{query.frsfzzmSc,jdbcType=VARCHAR}
  111. </if>
  112. <if test="query.extDrugEnt != null and query.extDrugEnt!=''">
  113. AND ext_drug_ent = #{query.extDrugEnt,jdbcType=VARCHAR}
  114. </if>
  115. <if test="query.qylx != null and query.qylx!=''">
  116. AND qylx = #{query.qylx,jdbcType=VARCHAR}
  117. </if>
  118. <if test="query.csmUserIdList != null and query.csmUserIdList.size() > 0">
  119. and dc.user_id in (
  120. <foreach collection="query.csmUserIdList" item="userId" index="index" separator=",">
  121. #{userId}
  122. </foreach>
  123. )
  124. </if>
  125. </where>
  126. ORDER BY id DESC
  127. </select>
  128. <select id="selectWmManagementList" resultMap="wmDaAgentMap">
  129. select
  130. *
  131. from wm_da_agent where 1=1
  132. <if test="query.gsmc != null and query.gsmc !=''">
  133. AND gsmc like CONCAT('%',#{query.gsmc},'%')
  134. </if>
  135. <if test="query.zjNumber != null and query.zjNumber !=''">
  136. AND zj_number like CONCAT('%',#{query.zjNumber},'%')
  137. </if>
  138. <if test="query.pgqx != null and query.pgqx!=''">
  139. AND pgqx = #{query.pgqx,jdbcType=VARCHAR}
  140. </if>
  141. <if test="query.updateTime != null and query.updateTime !=''">
  142. AND update_time = #{query.updateTime,jdbcType=VARCHAR}
  143. </if>
  144. <if test="query.createTime != null and query.createTime!='' ">
  145. AND create_time = #{query.createTime,jdbcType=VARCHAR}
  146. </if>
  147. <if test="query.yyzz != null and query.yyzz!='' ">
  148. AND yyzz = #{query.yyzz,jdbcType=VARCHAR}
  149. </if>
  150. <if test="query.sbjnzm != null and query.sbjnzm!='' ">
  151. AND sbjnzm = #{query.sbjnzm,jdbcType=VARCHAR}
  152. </if>
  153. <if test="query.frsfzzmZm != null and query.frsfzzmZm!='' ">
  154. AND frsfzzm_zm = #{query.frsfzzmZm,jdbcType=VARCHAR}
  155. </if>
  156. <if test="query.frsfzzmBm != null and query.frsfzzmBm!='' ">
  157. AND frsfzzm_bm = #{query.frsfzzmBm,jdbcType=VARCHAR}
  158. </if>
  159. <if test="query.frsfzzmSc != null and query.frsfzzmSc!=''">
  160. AND frsfzzm_sc = #{query.frsfzzmSc,jdbcType=VARCHAR}
  161. </if>
  162. <if test="query.extDrugEnt != null and query.extDrugEnt!=''">
  163. AND ext_drug_ent = #{query.extDrugEnt,jdbcType=VARCHAR}
  164. </if>
  165. <if test="query.qylx != null and query.qylx!=''">
  166. AND qylx = #{query.qylx,jdbcType=VARCHAR}
  167. </if>
  168. order by id desc
  169. </select>
  170. <select id="selectExtDrugEntList" resultMap="wmDaAgentMap">
  171. select
  172. ext_drug_ent
  173. from wm_da_agent
  174. where
  175. gsmc = #{query.gsmc,jdbcType=VARCHAR}
  176. </select>
  177. <select id="selectByGsmcList" resultMap="wmDaAgentMap">
  178. select
  179. *
  180. from wm_da_agent
  181. where
  182. gsmc = #{query.gsmc,jdbcType=VARCHAR}
  183. </select>
  184. <select id="selectByGsmc" resultMap="wmDaAgentMap">
  185. select
  186. *
  187. from wm_da_agent
  188. where
  189. gsmc = #{query.gsmc,jdbcType=VARCHAR}
  190. </select>
  191. <select id="selectDeptId" resultMap="wmDaAgentMap">
  192. select
  193. a.*, d.dept_permissions
  194. from wm_da_agent a
  195. left join sys_dept d
  196. on a.dept_id = d.dept_id
  197. where
  198. a.dept_id = #{deptId,jdbcType=VARCHAR}
  199. </select>
  200. <select id="selectDeptId1" resultType="java.util.HashMap">
  201. select
  202. cast(id as char) as id,gsmc as name
  203. from wm_da_agent
  204. where
  205. dept_id = #{deptId,jdbcType=VARCHAR}
  206. </select>
  207. <select id="selectExtDrugEnt" resultMap="wmDaAgentMap">
  208. select
  209. *
  210. from wm_da_agent
  211. where
  212. ext_drug_ent = #{extDrugEnt,jdbcType=VARCHAR}
  213. </select>
  214. <select id="selectByDeptId" resultMap="wmDaAgentMap" parameterType="java.lang.String">
  215. select
  216. *
  217. from wm_da_agent
  218. where dept_id = #{deptId,jdbcType=VARCHAR}
  219. </select>
  220. <select id="selectByDeptIds" resultMap="wmDaAgentMap" parameterType="java.lang.Integer">
  221. select
  222. *
  223. from wm_da_agent
  224. where dept_id = #{deptId,jdbcType=VARCHAR}
  225. </select>
  226. <select id="selectByDrugIds" resultMap="wmDaAgentMap" parameterType="java.util.HashMap">
  227. select d.*
  228. from wm_da_agent d
  229. left join wm_relation r on r.down_id=d.id
  230. where r.up_id = #{upId,jdbcType=INTEGER}
  231. UNION
  232. select * from wm_da_agent where id= #{Id,jdbcType=INTEGER}
  233. </select>
  234. <select id="selectByDrugId" resultMap="wmDaAgentMap" parameterType="java.util.HashMap">
  235. select d.id,d.gsmc
  236. from wm_da_agent d
  237. left join wm_relation r on r.down_id=d.id
  238. left join wm_da_drug_ent o on r.up_id=o.id
  239. where r.up_id = #{upId,jdbcType=INTEGER}
  240. UNION
  241. select id,entname from wm_da_drug_ent where id= #{Id,jdbcType=INTEGER}
  242. </select>
  243. <select id="selectByRelationId" resultMap="wmDaAgentMap" parameterType="java.lang.Integer">
  244. select *
  245. from
  246. wm_da_agent
  247. where id= #{Id,jdbcType=INTEGER}
  248. </select>
  249. <select id="selectByRelationIds" resultMap="wmDaAgentMap" parameterType="java.util.HashMap">
  250. select d.*
  251. from wm_da_agent d
  252. left join wm_relation r on r.down_id=d.dept_id
  253. where r.up_id = #{upId,jdbcType=INTEGER}
  254. </select>
  255. <select id="selectEntNameByDrugIds" resultMap="wmDaAgentMap" parameterType="java.util.HashMap">
  256. select d.id,d.entname
  257. from wm_da_drug_ent d
  258. left join wm_relation r on r.down_id=d.id
  259. left join wm_da_drug_ent o on r.up_id=o.id
  260. where r.up_id = #{upId,jdbcType=INTEGER}
  261. UNION
  262. select id,gsmc from wm_da_agent where id= #{Id,jdbcType=INTEGER}
  263. </select>
  264. <select id="selectByUserDeptId" resultMap="wmDaAgentMap" parameterType="java.lang.Integer">
  265. select
  266. *
  267. from wm_da_agent
  268. where dept_id = #{deptId,jdbcType=VARCHAR}
  269. </select>
  270. <select id="selectWmDaDrugEntByDeptIds" resultMap="wmDaAgentMap" parameterType="java.util.HashMap">
  271. select d.*
  272. from wm_da_agent d
  273. left join wm_relation r on r.down_id=d.dept_id
  274. where r.up_id = #{upId,jdbcType=INTEGER}
  275. UNION
  276. select * from wm_da_agent where dept_id= #{deptId,jdbcType=VARCHAR}
  277. </select>
  278. <select id="selectWmDaDrugEntByDeptId" resultMap="wmDaAgentMap" parameterType="java.util.HashMap">
  279. select d.id,d.gsmc
  280. from wm_da_agent d
  281. left join wm_relation r on r.down_id=d.dept_id
  282. left join wm_da_drug_ent o on r.up_id=o.dept_id
  283. where r.up_id = #{upId,jdbcType=INTEGER}
  284. UNION
  285. select id,entname from wm_da_drug_ent where dept_id= #{deptId,jdbcType=INTEGER}
  286. </select>
  287. <select id="selectWmDaAgentByRelationId" resultMap="wmDaAgentMap" parameterType="java.lang.Integer">
  288. select *
  289. from
  290. wm_da_agent
  291. where dept_id= #{deptId,jdbcType=INTEGER}
  292. </select>
  293. <select id="selectWmDaAgentByRelationIds" resultMap="wmDaAgentMap" parameterType="java.util.HashMap">
  294. select d.*
  295. from wm_da_agent d
  296. left join wm_relation r on r.down_id=d.dept_id
  297. where r.up_id = #{upId,jdbcType=INTEGER}
  298. </select>
  299. <select id="selectWmDaAgentByDeptId" resultMap="wmDaAgentMap" parameterType="java.util.HashMap">
  300. select d.id,d.gsmc,d.enable_flag
  301. from wm_da_agent d
  302. left join wm_relation r on r.down_id=d.dept_id
  303. left join wm_da_drug_ent o on r.up_id=o.dept_id
  304. where r.up_id = #{upId,jdbcType=INTEGER}
  305. UNION
  306. select id,entname,enable_flag from wm_da_drug_ent where dept_id= #{deptId,jdbcType=INTEGER}
  307. </select>
  308. <select id="selectWmDaAgentByDeptIds" resultMap="wmDaAgentMap" parameterType="java.lang.String">
  309. select *
  310. from
  311. wm_da_agent
  312. where dept_id= #{deptId,jdbcType=VARCHAR}
  313. </select>
  314. <!-- 根据sys_dept表的level字段查询 -->
  315. <select id="listAgentByDeptLevel" resultMap="wmDaAgentMap">
  316. SELECT a.*
  317. FROM wm_da_agent a
  318. LEFT JOIN sys_dept d ON d.dept_id = a.dept_id
  319. WHERE a.del_flag = 0
  320. AND a.enable_flag = 0
  321. AND d.level = #{deptLevel}
  322. </select>
  323. <!-- 根据deptRelation查询 -->
  324. <select id="listAgentByDeptRelation" resultMap="wmDaAgentMap">
  325. SELECT
  326. *
  327. FROM
  328. wm_da_agent a
  329. LEFT JOIN sys_dept_relation r ON r.descendant = a.dept_id
  330. WHERE
  331. r.ancestor = #{deptId, jdbcType=INTEGER}
  332. </select>
  333. </mapper>