ImpPersInfoDao.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  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="cn.com.goldenwater.dcproj.dao.ImpPersInfoDao">
  4. <resultMap type="cn.com.goldenwater.dcproj.model.ImpPersInfo" id="impPersInfoResultMap">
  5. <result property="id" column="ID"/>
  6. <result property="num" column="NUM"/>
  7. <result property="orgId" column="ORG_ID"/>
  8. <result property="orgNm" column="ORG_NM"/>
  9. <result property="adCode" column="AD_CODE"/>
  10. <result property="adName" column="AD_NAME"/>
  11. <result property="leadId" column="LEAD_ID"/>
  12. <result property="leadName" column="LEAD_NAME"/>
  13. <result property="leadUnitJob" column="LEAD_UNIT_JOB"/>
  14. <result property="crewId" column="CREW_ID"/>
  15. <result property="crewName" column="CREW_NAME"/>
  16. <result property="crewUnitJob" column="CREW_UNIT_JOB"/>
  17. <result property="lisonId" column="LISON_ID"/>
  18. <result property="lisonName" column="LISON_NAME"/>
  19. <result property="lisonUnitJob" column="LISON_UNIT_JOB"/>
  20. <result property="mnth" column="MNTH"/>
  21. <result property="oldGroupId" column="OLD_GROUP_ID"/>
  22. <result property="groupId" column="GROUP_ID"/>
  23. <result property="groupNm" column="GROUP_NM"/>
  24. </resultMap>
  25. <sql id="table_columns">
  26. ID,
  27. NUM,
  28. ORG_ID,
  29. ORG_NM,
  30. AD_CODE,
  31. AD_NAME,
  32. LEAD_ID,
  33. LEAD_NAME,
  34. LEAD_UNIT_JOB,
  35. CREW_ID,
  36. CREW_NAME,
  37. CREW_UNIT_JOB,
  38. LISON_ID,
  39. LISON_NAME,
  40. LISON_UNIT_JOB,
  41. MNTH,
  42. OLD_GROUP_ID,
  43. GROUP_ID,
  44. GROUP_NM
  45. </sql>
  46. <sql id="entity_properties">
  47. #{id},
  48. #{num},
  49. #{orgId},
  50. #{orgNm},
  51. #{adCode},
  52. #{adName},
  53. #{leadId},
  54. #{leadName},
  55. #{leadUnitJob},
  56. #{crewId},
  57. #{crewName},
  58. #{crewUnitJob},
  59. #{lisonId},
  60. #{lisonName},
  61. #{lisonUnitJob},
  62. #{mnth},
  63. #{oldGroupId},
  64. #{groupId},
  65. #{groupNm}
  66. </sql>
  67. <!-- 使用like用法:columnName like concat('%',#columnName#,'%') -->
  68. <sql id="page_where">
  69. <trim prefix="where" prefixOverrides="and | or ">
  70. <if test="num != null and num != ''">and NUM = #{num}</if>
  71. <if test="orgId != null and orgId != ''">and ORG_ID = #{orgId}</if>
  72. <if test="orgNm != null and orgNm != ''">and ORG_NM = #{orgNm}</if>
  73. <if test="adCode != null and adCode != ''">and AD_CODE = #{adCode}</if>
  74. <if test="adName != null and adName != ''">and AD_NAME = #{adName}</if>
  75. <if test="leadId != null and leadId != ''">and LEAD_ID = #{leadId}</if>
  76. <if test="leadName != null and leadName != ''">and LEAD_NAME = #{leadName}</if>
  77. <if test="leadUnitJob != null and leadUnitJob != ''">and LEAD_UNIT_JOB = #{leadUnitJob}</if>
  78. <if test="crewId != null and crewId != ''">and CREW_ID = #{crewId}</if>
  79. <if test="crewName != null and crewName != ''">and CREW_NAME = #{crewName}</if>
  80. <if test="crewUnitJob != null and crewUnitJob != ''">and CREW_UNIT_JOB = #{crewUnitJob}</if>
  81. <if test="lisonId != null and lisonId != ''">and LISON_ID = #{lisonId}</if>
  82. <if test="lisonName != null and lisonName != ''">and LISON_NAME = #{lisonName}</if>
  83. <if test="lisonUnitJob != null and lisonUnitJob != ''">and LISON_UNIT_JOB = #{lisonUnitJob}</if>
  84. <if test="mnth != null and mnth != ''">and MNTH = #{mnth}</if>
  85. <if test="oldGroupId != null and oldGroupId != ''">and OLD_GROUP_ID = #{oldGroupId}</if>
  86. <if test="groupId != null and groupId != ''">and GROUP_ID = #{groupId}</if>
  87. <if test="groupNm != null and groupNm != ''">and GROUP_NM = #{groupNm}</if>
  88. <if test="isLead != null and isLead != ''">and LEAD_ID is not null </if>
  89. </trim>
  90. </sql>
  91. <select id="get" resultMap="impPersInfoResultMap" parameterType="String">
  92. select
  93. <include refid="table_columns"/>
  94. from IMP_PERS_INFO where ID = #{id}
  95. </select>
  96. <select id="getBy" resultMap="impPersInfoResultMap">
  97. select
  98. <include refid="table_columns"/>
  99. from IMP_PERS_INFO
  100. <include refid="page_where"/>
  101. </select>
  102. <select id="findAll" resultMap="impPersInfoResultMap">
  103. select
  104. <include refid="table_columns"/>
  105. from IMP_PERS_INFO order by to_number(num)
  106. </select>
  107. <select id="findList" resultMap="impPersInfoResultMap">
  108. select
  109. <include refid="table_columns"/>
  110. from IMP_PERS_INFO
  111. <include refid="page_where"/>
  112. order by to_number(num)
  113. </select>
  114. <select id="getList" resultMap="impPersInfoResultMap">
  115. select <include refid="table_columns" /> from IMP_PERS_INFO where LEAD_ID is not null <include refid="page_where" />
  116. order by to_number(num)
  117. </select>
  118. <select id="selectCount" resultType="int">
  119. select count(ID) from IMP_PERS_INFO
  120. <include refid="page_where"/>
  121. </select>
  122. <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.ImpPersInfo">
  123. insert into IMP_PERS_INFO(
  124. <include refid="table_columns"/>
  125. )
  126. values (
  127. <include refid="entity_properties"/>
  128. )
  129. </insert>
  130. <delete id="delete" parameterType="java.lang.String">
  131. delete from IMP_PERS_INFO where ID = #{id}
  132. </delete>
  133. <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.ImpPersInfo">
  134. delete from IMP_PERS_INFO
  135. <include refid="page_where"/>
  136. </delete>
  137. <update id="deleteInFlag" parameterType="java.lang.String">
  138. update IMP_PERS_INFO set flag_valid = 0 where ID = #{id}
  139. </update>
  140. <update id="update" parameterType="cn.com.goldenwater.dcproj.model.ImpPersInfo">
  141. update IMP_PERS_INFO
  142. <trim prefix="set" suffixOverrides=",">
  143. <if test="num != null and num != ''">NUM = #{num},</if>
  144. <if test="orgId != null and orgId != ''">ORG_ID = #{orgId},</if>
  145. <if test="orgNm != null and orgNm != ''">ORG_NM = #{orgNm},</if>
  146. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  147. <if test="adName != null and adName != ''">AD_NAME = #{adName},</if>
  148. <if test="leadId != null and leadId != ''">LEAD_ID = #{leadId},</if>
  149. <if test="leadName != null and leadName != ''">LEAD_NAME = #{leadName},</if>
  150. <if test="leadUnitJob != null and leadUnitJob != ''">LEAD_UNIT_JOB = #{leadUnitJob},</if>
  151. <if test="crewId != null and crewId != ''">CREW_ID = #{crewId},</if>
  152. <if test="crewName != null and crewName != ''">CREW_NAME = #{crewName},</if>
  153. <if test="crewUnitJob != null and crewUnitJob != ''">CREW_UNIT_JOB = #{crewUnitJob},</if>
  154. <if test="lisonId != null and lisonId != ''">LISON_ID = #{lisonId},</if>
  155. <if test="lisonName != null and lisonName != ''">LISON_NAME = #{lisonName},</if>
  156. <if test="lisonUnitJob != null and lisonUnitJob != ''">LISON_UNIT_JOB = #{lisonUnitJob},</if>
  157. <if test="mnth != null and mnth != ''">MNTH = #{mnth},</if>
  158. <if test="oldGroupId != null and oldGroupId != ''">OLD_GROUP_ID = #{oldGroupId},</if>
  159. <if test="groupId != null and groupId != ''">GROUP_ID = #{groupId},</if>
  160. <if test="groupNm != null and groupNm != ''">GROUP_NM = #{groupNm},</if>
  161. </trim>
  162. <where>ID = #{id}</where>
  163. </update>
  164. <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.ImpPersInfo">
  165. update IMP_PERS_INFO
  166. <trim prefix="set" suffixOverrides=",">
  167. <if test="num != null and num != ''">NUM = #{num},</if>
  168. <if test="orgId != null and orgId != ''">ORG_ID = #{orgId},</if>
  169. <if test="orgNm != null and orgNm != ''">ORG_NM = #{orgNm},</if>
  170. <if test="adCode != null and adCode != ''">AD_CODE = #{adCode},</if>
  171. <if test="adName != null and adName != ''">AD_NAME = #{adName},</if>
  172. <if test="leadId != null and leadId != ''">LEAD_ID = #{leadId},</if>
  173. <if test="leadName != null and leadName != ''">LEAD_NAME = #{leadName},</if>
  174. <if test="leadUnitJob != null and leadUnitJob != ''">LEAD_UNIT_JOB = #{leadUnitJob},</if>
  175. <if test="crewId != null and crewId != ''">CREW_ID = #{crewId},</if>
  176. <if test="crewName != null and crewName != ''">CREW_NAME = #{crewName},</if>
  177. <if test="crewUnitJob != null and crewUnitJob != ''">CREW_UNIT_JOB = #{crewUnitJob},</if>
  178. <if test="lisonId != null and lisonId != ''">LISON_ID = #{lisonId},</if>
  179. <if test="lisonName != null and lisonName != ''">LISON_NAME = #{lisonName},</if>
  180. <if test="lisonUnitJob != null and lisonUnitJob != ''">LISON_UNIT_JOB = #{lisonUnitJob},</if>
  181. <if test="mnth != null and mnth != ''">MNTH = #{mnth},</if>
  182. <if test="oldGroupId != null and oldGroupId != ''">OLD_GROUP_ID = #{oldGroupId},</if>
  183. <if test="groupId != null and groupId != ''">GROUP_ID = #{groupId},</if>
  184. <if test="groupNm != null and groupNm != ''">GROUP_NM = #{groupNm},</if>
  185. </trim>
  186. <include refid="page_where"/>
  187. </update>
  188. <!-- 其他自定义SQL -->
  189. <select id="getGroupId" parameterType="java.util.Map" resultType="java.util.Map">
  190. SELECT A.PERSID,A.PERTYPE,B.*,C.AD_CODE,C.AD_NAME FROM BIS_INSP_ALL_RLATION A
  191. LEFT JOIN BIS_INSP_ALL B ON A.ID = B.ID
  192. LEFT JOIN BIS_INSP_SEL_AREA C ON A.ID = C.ID
  193. WHERE 1=1
  194. <if test="persId != null and persId != ''"> AND A.PERSID = #{persId}</if>
  195. <if test="persType != null and persType != ''"> AND A.PERTYPE = #{persType}</if>
  196. <if test="mnth != null and mnth != ''"> AND B.INSP_MNTH = #{mnth}</if>
  197. <if test="id != null and id != ''"> AND A.ID LIKE concat(#{id},'%')</if>
  198. <if test="adCd != null and adCd != ''"> AND C.AD_CODE LIKE concat(#{adCd},'%')</if>
  199. <if test="persIds != null and persIds != ''"> AND A.PERSID in
  200. <foreach item="item" index="index" collection="persIds.split(',')" open="(" separator="," close=")">
  201. '${item}'
  202. </foreach>
  203. </if>
  204. ORDER BY A.ID
  205. </select>
  206. <select id="getOldGroups" parameterType="java.util.Map" resultType="java.util.Map">
  207. SELECT A.PERSID,A.PERTYPE,B.* FROM BIS_INSP_ALL_RLATION A
  208. LEFT JOIN BIS_INSP_ALL B ON A.ID = B.ID
  209. WHERE 1=1
  210. <if test="persId != null and persId != ''"> AND A.PERSID = #{persId}</if>
  211. <if test="persType != null and persType != ''"> AND A.PERTYPE = #{persType}</if>
  212. <if test="mnth != null and mnth != ''"> AND B.INSP_MNTH = #{mnth}</if>
  213. <if test="id != null and id != ''"> AND A.ID LIKE concat(#{id},'%')</if>
  214. <if test="persIds != null and persIds != ''"> AND A.PERSID in
  215. <foreach item="item" index="index" collection="persIds.split(',')" open="(" separator="," close=")">
  216. '${item}'
  217. </foreach>
  218. </if>
  219. ORDER BY A.ID
  220. </select>
  221. <select id="getNewGroups" parameterType="java.util.Map" resultType="java.util.Map">
  222. SELECT distinct B.*,C.AD_CODE,C.AD_NAME FROM BIS_INSP_ALL_RLATION A
  223. LEFT JOIN BIS_INSP_ALL B ON A.ID = B.ID
  224. LEFT JOIN BIS_INSP_SEL_AREA C ON A.ID = C.ID
  225. WHERE 1=1
  226. <if test="persId != null and persId != ''"> AND A.PERSID = #{persId}</if>
  227. <if test="persType != null and persType != ''"> AND A.PERTYPE = #{persType}</if>
  228. <if test="mnth != null and mnth != ''"> AND B.INSP_MNTH = #{mnth}</if>
  229. <if test="id != null and id != ''"> AND A.ID LIKE concat(#{id},'%')</if>
  230. <if test="adCd != null and adCd != ''"> AND C.AD_CODE LIKE concat(#{adCd},'%')</if>
  231. <if test="persIds != null and persIds != ''"> AND A.PERSID in
  232. <foreach item="item" index="index" collection="persIds.split(',')" open="(" separator="," close=")">
  233. '${item}'
  234. </foreach>
  235. </if>
  236. <if test="regId != null and regId != ''"> AND A.PERSID in (select d.rec_pers_id from bis_insp_rsvr_rgstr b
  237. left join BIS_INSP_RSVR_PROJECT d on b.rgstr_id = d.rgstr_id
  238. left join BIS_INSP_ALL_RLATION_PERS c on d.rec_pers_id = c.guid
  239. where b.rgstr_id = #{regId})
  240. </if>
  241. ORDER BY B.ID
  242. </select>
  243. <select id="getGroupIdByReg" parameterType="java.util.Map" resultType="java.util.Map">
  244. SELECT distinct B.*,C.AD_CODE,C.AD_NAME FROM BIS_INSP_ALL_RLATION A
  245. LEFT JOIN BIS_INSP_ALL B ON A.ID = B.ID
  246. LEFT JOIN BIS_INSP_SEL_AREA C ON A.ID = C.ID
  247. WHERE 1=1
  248. <if test="persId != null and persId != ''"> AND A.PERSID = #{persId}</if>
  249. <if test="regId != null and regId != ''"> AND A.PERSID in (select d.rec_pers_id from bis_insp_rsvr_rgstr b
  250. left join BIS_INSP_RSVR_PROJECT d on b.rgstr_id = d.rgstr_id
  251. left join BIS_INSP_ALL_RLATION_PERS c on d.rec_pers_id = c.guid
  252. where b.rgstr_id = #{regId})
  253. </if>
  254. <if test="mnth != null and mnth != ''"> AND B.INSP_MNTH = #{mnth}</if>
  255. <if test="id != null and id != ''"> AND A.ID LIKE concat(#{id},'%')</if>
  256. <if test="adCd != null and adCd != ''"> AND C.AD_CODE LIKE concat(#{adCd},'%')</if>
  257. ORDER BY B.ID
  258. </select>
  259. </mapper>