BaseCompanyDao.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  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.liang.dao.BaseCompanyDao">
  4. <resultMap type="com.liang.entity.BaseCompany" id="BaseCompanyMap">
  5. <result property="id" column="ID" jdbcType="INTEGER"/>
  6. <result property="mc" column="MC" jdbcType="VARCHAR"/>
  7. <result property="szd" column="SZD" jdbcType="VARCHAR"/>
  8. <result property="txdz" column="TXDZ" jdbcType="VARCHAR"/>
  9. <result property="yzbm" column="YZBM" jdbcType="VARCHAR"/>
  10. <result property="dwxz" column="DWXZ" jdbcType="VARCHAR"/>
  11. <result property="lxr" column="LXR" jdbcType="INTEGER"/>
  12. <result property="xm" column="XM" jdbcType="VARCHAR"/>
  13. <result property="gddh" column="GDDH" jdbcType="VARCHAR"/>
  14. <result property="dzyj" column="DZYJ" jdbcType="VARCHAR"/>
  15. <result property="yddh" column="YDDH" jdbcType="VARCHAR"/>
  16. <result property="cz" column="CZ" jdbcType="VARCHAR"/>
  17. <result property="lxrxq" column="LXRXQ" jdbcType="VARCHAR"/>
  18. <result property="bm" column="BM" jdbcType="VARCHAR"/>
  19. <result property="fbm" column="FBM" jdbcType="VARCHAR"/>
  20. <result property="spx" column="SPX" jdbcType="VARCHAR"/>
  21. <result property="lx" column="LX" jdbcType="INTEGER"/>
  22. <result property="dwqc" column="DWQC" jdbcType="VARCHAR"/>
  23. <result property="sfkybg" column="SFKYBG" jdbcType="VARCHAR"/>
  24. <result property="xtdw" column="XTDW" jdbcType="INTEGER"/>
  25. <result property="cjr" column="CJR" jdbcType="INTEGER"/>
  26. <result property="px" column="PX" jdbcType="VARCHAR"/>
  27. </resultMap>
  28. <!--查询单个-->
  29. <select id="queryById" resultMap="BaseCompanyMap">
  30. select c.*, t.name as dwxzmc, p.xm as lxrxm
  31. from base_Company c
  32. left join base_CompanyType t on t.id = c.DWXZ
  33. left join base_Person p on p.id = c.lxr
  34. where c.ID = #{id}
  35. </select>
  36. <!--查询指定行数据-->
  37. <select id="queryAllByLimit" resultMap="BaseCompanyMap">
  38. select
  39. ID, MC, SZD, TXDZ, YZBM, DWXZ, LXR, XM, GDDH, DZYJ, YDDH, CZ, LXRXQ, BM, FBM, SPX, LX, DWQC, SFKYBG, XTDW, CJR,
  40. PX
  41. from base_Company
  42. <where>
  43. <if test="id != null">
  44. and ID = #{id}
  45. </if>
  46. <if test="mc != null and mc != ''">
  47. and MC = #{mc}
  48. </if>
  49. <if test="szd != null and szd != ''">
  50. and SZD = #{szd}
  51. </if>
  52. <if test="txdz != null and txdz != ''">
  53. and TXDZ = #{txdz}
  54. </if>
  55. <if test="yzbm != null and yzbm != ''">
  56. and YZBM = #{yzbm}
  57. </if>
  58. <if test="dwxz != null and dwxz != ''">
  59. and DWXZ = #{dwxz}
  60. </if>
  61. <if test="lxr != null">
  62. and LXR = #{lxr}
  63. </if>
  64. <if test="xm != null and xm != ''">
  65. and XM = #{xm}
  66. </if>
  67. <if test="gddh != null and gddh != ''">
  68. and GDDH = #{gddh}
  69. </if>
  70. <if test="dzyj != null and dzyj != ''">
  71. and DZYJ = #{dzyj}
  72. </if>
  73. <if test="yddh != null and yddh != ''">
  74. and YDDH = #{yddh}
  75. </if>
  76. <if test="cz != null and cz != ''">
  77. and CZ = #{cz}
  78. </if>
  79. <if test="lxrxq != null">
  80. and LXRXQ = #{lxrxq}
  81. </if>
  82. <if test="bm != null and bm != ''">
  83. and BM = #{bm}
  84. </if>
  85. <if test="fbm != null and fbm != ''">
  86. and FBM = #{fbm}
  87. </if>
  88. <if test="spx != null and spx != ''">
  89. and SPX = #{spx}
  90. </if>
  91. <if test="lx != null">
  92. and LX = #{lx}
  93. </if>
  94. <if test="dwqc != null and dwqc != ''">
  95. and DWQC = #{dwqc}
  96. </if>
  97. <if test="sfkybg != null">
  98. and SFKYBG = #{sfkybg}
  99. </if>
  100. <if test="xtdw != null">
  101. and XTDW = #{xtdw}
  102. </if>
  103. <if test="cjr != null">
  104. and CJR = #{cjr}
  105. </if>
  106. <if test="px != null and px != ''">
  107. and PX = #{px}
  108. </if>
  109. </where>
  110. limit #{pageable.offset}, #{pageable.pageSize}
  111. </select>
  112. <!--统计总行数-->
  113. <select id="count" resultType="java.lang.Long">
  114. select count(1)
  115. from base_Company
  116. <where>
  117. <if test="id != null">
  118. and ID = #{id}
  119. </if>
  120. <if test="mc != null and mc != ''">
  121. and MC = #{mc}
  122. </if>
  123. <if test="szd != null and szd != ''">
  124. and SZD = #{szd}
  125. </if>
  126. <if test="txdz != null and txdz != ''">
  127. and TXDZ = #{txdz}
  128. </if>
  129. <if test="yzbm != null and yzbm != ''">
  130. and YZBM = #{yzbm}
  131. </if>
  132. <if test="dwxz != null and dwxz != ''">
  133. and DWXZ = #{dwxz}
  134. </if>
  135. <if test="lxr != null">
  136. and LXR = #{lxr}
  137. </if>
  138. <if test="xm != null and xm != ''">
  139. and XM = #{xm}
  140. </if>
  141. <if test="gddh != null and gddh != ''">
  142. and GDDH = #{gddh}
  143. </if>
  144. <if test="dzyj != null and dzyj != ''">
  145. and DZYJ = #{dzyj}
  146. </if>
  147. <if test="yddh != null and yddh != ''">
  148. and YDDH = #{yddh}
  149. </if>
  150. <if test="cz != null and cz != ''">
  151. and CZ = #{cz}
  152. </if>
  153. <if test="lxrxq != null">
  154. and LXRXQ = #{lxrxq}
  155. </if>
  156. <if test="bm != null and bm != ''">
  157. and BM = #{bm}
  158. </if>
  159. <if test="fbm != null and fbm != ''">
  160. and FBM = #{fbm}
  161. </if>
  162. <if test="spx != null and spx != ''">
  163. and SPX = #{spx}
  164. </if>
  165. <if test="lx != null">
  166. and LX = #{lx}
  167. </if>
  168. <if test="dwqc != null and dwqc != ''">
  169. and DWQC = #{dwqc}
  170. </if>
  171. <if test="sfkybg != null">
  172. and SFKYBG = #{sfkybg}
  173. </if>
  174. <if test="xtdw != null">
  175. and XTDW = #{xtdw}
  176. </if>
  177. <if test="cjr != null">
  178. and CJR = #{cjr}
  179. </if>
  180. <if test="px != null and px != ''">
  181. and PX = #{px}
  182. </if>
  183. </where>
  184. </select>
  185. <!--新增所有列-->
  186. <insert id="insert" keyProperty="id" useGeneratedKeys="true">
  187. if not exists (select * from base_Company where dwqc = #{dwqc})
  188. insert into base_Company (MC, SZD, TXDZ, YZBM, DWXZ, LXR, XM, GDDH, DZYJ, YDDH, CZ, LXRXQ, BM, FBM, SPX, LX, DWQC, SFKYBG, XTDW, CJR, PX)
  189. values (#{mc}, #{szd}, #{txdz}, #{yzbm}, #{dwxz}, #{lxr}, #{xm},#{gddh}, #{dzyj}, #{yddh}, #{cz}, #{lxrxq}, #{bm}, #{fbm},
  190. #{spx}, #{lx}, #{dwqc}, #{sfkybg}, #{xtdw}, #{cjr}, #{px})
  191. </insert>
  192. <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
  193. insert into base_Company(MC, SZD, TXDZ, YZBM, DWXZ, LXR, XM, GDDH, DZYJ, YDDH, CZ, LXRXQ, BM, FBM, SPX, LX,
  194. DWQC, SFKYBG, XTDW, CJR, PX)
  195. values
  196. <foreach collection="entities" item="entity" separator=",">
  197. (#{entity.mc}, #{entity.szd}, #{entity.txdz}, #{entity.yzbm}, #{entity.dwxz}, #{entity.lxr}, #{entity.xm},
  198. #{entity.gddh}, #{entity.dzyj}, #{entity.yddh}, #{entity.cz}, #{entity.lxrxq}, #{entity.bm}, #{entity.fbm},
  199. #{entity.spx}, #{entity.lx}, #{entity.dwqc}, #{entity.sfkybg}, #{entity.xtdw}, #{entity.cjr}, #{entity.px})
  200. </foreach>
  201. </insert>
  202. <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
  203. insert into base_Company(MC, SZD, TXDZ, YZBM, DWXZ, LXR, XM, GDDH, DZYJ, YDDH, CZ, LXRXQ, BM, FBM, SPX, LX,
  204. DWQC, SFKYBG, XTDW, CJR, PX)
  205. values
  206. <foreach collection="entities" item="entity" separator=",">
  207. (#{entity.mc}, #{entity.szd}, #{entity.txdz}, #{entity.yzbm}, #{entity.dwxz}, #{entity.lxr}, #{entity.xm},
  208. #{entity.gddh}, #{entity.dzyj}, #{entity.yddh}, #{entity.cz}, #{entity.lxrxq}, #{entity.bm}, #{entity.fbm},
  209. #{entity.spx}, #{entity.lx}, #{entity.dwqc}, #{entity.sfkybg}, #{entity.xtdw}, #{entity.cjr}, #{entity.px})
  210. </foreach>
  211. on duplicate key update
  212. MC = values(MC),
  213. SZD = values(SZD),
  214. TXDZ = values(TXDZ),
  215. YZBM = values(YZBM),
  216. DWXZ = values(DWXZ),
  217. LXR = values(LXR),
  218. XM = values(XM),
  219. GDDH = values(GDDH),
  220. DZYJ = values(DZYJ),
  221. YDDH = values(YDDH),
  222. CZ = values(CZ),
  223. LXRXQ = values(LXRXQ),
  224. BM = values(BM),
  225. FBM = values(FBM),
  226. SPX = values(SPX),
  227. LX = values(LX),
  228. DWQC = values(DWQC),
  229. SFKYBG = values(SFKYBG),
  230. XTDW = values(XTDW),
  231. CJR = values(CJR),
  232. PX = values(PX)
  233. </insert>
  234. <!--通过主键修改数据-->
  235. <update id="update" parameterType="com.liang.entity.BaseCompany">
  236. update base_Company
  237. set BM = #{bm},
  238. MC = #{mc},
  239. DWQC = #{dwqc},
  240. LX = #{lx},
  241. SZD = #{szd},
  242. TXDZ = #{txdz},
  243. YZBM = #{yzbm},
  244. DWXZ = #{dwxz},
  245. LXR = #{lxr},
  246. XM = #{xm},
  247. GDDH = #{gddh},
  248. DZYJ = #{dzyj},
  249. YDDH = #{yddh},
  250. CZ = #{cz},
  251. PX = #{px}
  252. where ID = #{id}
  253. </update>
  254. <!--通过主键删除-->
  255. <delete id="deleteById">
  256. delete
  257. from base_Company
  258. where ID = #{id}
  259. </delete>
  260. <!--分页查询-->
  261. <select id="getBaseCompanyList" resultMap="BaseCompanyMap" parameterType="map">
  262. select c.ID, c.MC, c.DWQC,c.SZD, p.XM as LXRXM,
  263. case LX when '1' then '内部单位' when '2' then '外部单位' else '' end as LXMC
  264. from base_Company c
  265. left join base_Person p on p.ID = c.LXR
  266. where 1=1
  267. <if test="mc != null and mc != ''">
  268. and c.MC like '%'+#{mc}+'%'
  269. </if>
  270. <if test="dwqc != null and dwqc != ''">
  271. and c.DWQC like '%'+#{dwqc}+'%'
  272. </if>
  273. order by c.ID asc
  274. </select>
  275. <select id="list" resultMap="BaseCompanyMap">
  276. select * from base_Company
  277. </select>
  278. <!--校验单位全称是否唯一-->
  279. <select id="checkCompanyUnique" resultType="java.lang.Integer" parameterType="java.lang.String">
  280. select count(*) from base_Company where DWQC = #{DWQC}
  281. </select>
  282. <!--批量删除单位-->
  283. <delete id="batchDelete" parameterType="java.util.ArrayList">
  284. delete from base_Company
  285. where ID in
  286. <foreach item="item" index="index" collection="idList" open = "(" separator = "," close = ")">
  287. #{item}
  288. </foreach>
  289. </delete>
  290. </mapper>