AssRelcustomerinfoMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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.dgtly.system.mapper.AssRelcustomerinfoMapper">
  6. <resultMap type="AssRelcustomerinfo" id="AssRelcustomerinfoResult">
  7. <result property="id" column="id" />
  8. <result property="createBy" column="create_by" />
  9. <result property="createTime" column="create_time" />
  10. <result property="updateBy" column="update_by" />
  11. <result property="updateTime" column="update_time" />
  12. <result property="isDelete" column="is_delete" />
  13. <result property="mainkunnr" column="mainkunnr" />
  14. <result property="mainname1" column="mainname1" />
  15. <result property="kunnr" column="kunnr" />
  16. <result property="name1" column="name1" />
  17. <result property="glfs" column="glfs" />
  18. <result property="glsj" column="glsj" />
  19. <result property="enddate" column="enddate" />
  20. <result property="etlCreatetime" column="ETL_createtime" />
  21. <result property="customerType" column="customer_type" />
  22. </resultMap>
  23. <sql id="selectAssRelcustomerinfoVo">
  24. select id, create_by, create_time, update_by, update_time, is_delete, mainkunnr, mainname1, kunnr, name1, glfs, glsj, enddate, ETL_createtime,user_id,customer_type from ass_relcustomerinfo
  25. </sql>
  26. <select id="selectAssRelcustomerinfoList" parameterType="AssRelcustomerinfo" resultMap="AssRelcustomerinfoResult">
  27. <include refid="selectAssRelcustomerinfoVo"/>
  28. <where>
  29. <if test="isDelete != null "> and is_delete = #{isDelete}</if>
  30. <if test="mainkunnr != null and mainkunnr != ''"> and mainkunnr = #{mainkunnr}</if>
  31. <if test="mainname1 != null and mainname1 != ''"> and mainname1 = #{mainname1}</if>
  32. <if test="kunnr != null and kunnr != ''"> and kunnr = #{kunnr}</if>
  33. <if test="name1 != null and name1 != ''"> and name1 = #{name1}</if>
  34. <if test="glfs != null and glfs != ''"> and glfs = #{glfs}</if>
  35. <if test="glsj != null "> and glsj = #{glsj}</if>
  36. <if test="enddate != null "> and enddate = #{enddate}</if>
  37. <if test="etlCreatetime != null "> and ETL_createtime = #{etlCreatetime}</if>
  38. </where>
  39. </select>
  40. <select id="selectAssRelcustomerinfoById" parameterType="Long" resultMap="AssRelcustomerinfoResult">
  41. <include refid="selectAssRelcustomerinfoVo"/>
  42. where id = #{id}
  43. </select>
  44. <select id="selectRelcustomerinfoListByorgCode" resultMap="AssRelcustomerinfoResult">
  45. <include refid="selectAssRelcustomerinfoVo"/>
  46. WHERE
  47. glfs != '开票方关联'
  48. AND mainkunnr IN (
  49. SELECT
  50. ar.mainkunnr
  51. FROM
  52. ass_relcustomerinfo ar
  53. WHERE
  54. 1 = 1
  55. AND ( #{orgCode} = ar.mainkunnr OR #{orgCode} = ar.kunnr )
  56. and glfs !='用户关联'
  57. GROUP BY
  58. ar.mainkunnr
  59. )
  60. or user_id=#{userId}
  61. GROUP BY
  62. kunnr
  63. </select>
  64. <select id="selectRelcustomerinfoByKunnr" resultMap="AssRelcustomerinfoResult">
  65. <include refid="selectAssRelcustomerinfoVo"/>
  66. where
  67. glfs = '用户关联'
  68. <if test="kunnr !=null and kunnr !=''">
  69. and (kunnr =#{kunnr} or mainkunnr =#{kunnr})
  70. </if>
  71. <if test="userId !=null and userId !=''">
  72. and user_id=#{userId}
  73. </if>
  74. </select>
  75. <insert id="insertAssRelcustomerinfo" parameterType="AssRelcustomerinfo" useGeneratedKeys="true" keyProperty="id">
  76. insert into ass_relcustomerinfo
  77. <trim prefix="(" suffix=")" suffixOverrides=",">
  78. <if test="createBy != null and createBy != ''">create_by,</if>
  79. <if test="createTime != null ">create_time,</if>
  80. <if test="updateBy != null and updateBy != ''">update_by,</if>
  81. <if test="updateTime != null ">update_time,</if>
  82. <if test="isDelete != null ">is_delete,</if>
  83. <if test="mainkunnr != null and mainkunnr != ''">mainkunnr,</if>
  84. <if test="mainname1 != null and mainname1 != ''">mainname1,</if>
  85. <if test="kunnr != null and kunnr != ''">kunnr,</if>
  86. <if test="name1 != null and name1 != ''">name1,</if>
  87. <if test="glfs != null and glfs != ''">glfs,</if>
  88. <if test="glsj != null ">glsj,</if>
  89. <if test="enddate != null ">enddate,</if>
  90. <if test="etlCreatetime != null ">ETL_createtime,</if>
  91. <if test="userId != null ">user_id,</if>
  92. </trim>
  93. <trim prefix="values (" suffix=")" suffixOverrides=",">
  94. <if test="createBy != null and createBy != ''">#{createBy},</if>
  95. <if test="createTime != null ">#{createTime},</if>
  96. <if test="updateBy != null and updateBy != ''">#{updateBy},</if>
  97. <if test="updateTime != null ">#{updateTime},</if>
  98. <if test="isDelete != null ">#{isDelete},</if>
  99. <if test="mainkunnr != null and mainkunnr != ''">#{mainkunnr},</if>
  100. <if test="mainname1 != null and mainname1 != ''">#{mainname1},</if>
  101. <if test="kunnr != null and kunnr != ''">#{kunnr},</if>
  102. <if test="name1 != null and name1 != ''">#{name1},</if>
  103. <if test="glfs != null and glfs != ''">#{glfs},</if>
  104. <if test="glsj != null ">#{glsj},</if>
  105. <if test="enddate != null ">#{enddate},</if>
  106. <if test="etlCreatetime != null ">#{etlCreatetime},</if>
  107. <if test="userId != null ">#{userId},</if>
  108. </trim>
  109. </insert>
  110. <insert id="relationCustomerOnlineSync">
  111. insert into customers_start
  112. <trim prefix="(" suffix=")" suffixOverrides=",">
  113. <if test="mainkunnr != null and mainkunnr != ''">customers_code,</if>
  114. <if test="mainname1 != null and mainname1 !='' ">customers_name,</if>
  115. online_time,
  116. <if test="customerType != null and customerType !='' ">customer_type,</if>
  117. </trim>
  118. <trim prefix="values (" suffix=")" suffixOverrides=",">
  119. <if test="mainkunnr != null and mainkunnr != ''">#{mainkunnr},</if>
  120. <if test="mainname1 != null and mainname1 !=''">#{mainname1},</if>
  121. #{updateTime},
  122. <if test="customerType != null and customerType!='' ">#{customerType},</if>
  123. </trim>
  124. </insert>
  125. <select id="selectCustomerStart" resultType="java.lang.String">
  126. select customer_type from customers_start where 1=1
  127. <if test="customerCode !=null and customerCode !=''">
  128. and customers_code=#{customerCode}
  129. </if>
  130. <if test="customerType!=null and customerType !=''and type != 3 ">
  131. and customer_type=#{customerType}
  132. </if>
  133. <if test="customerType!=null and customerType !='' and type == 3 ">
  134. and (customer_type=#{customerType}
  135. or customer_type=3)
  136. </if>
  137. GROUP BY customer_type
  138. </select>
  139. <select id="selectCustomerByCustomerCode" resultType="java.lang.String">
  140. select customer_type from customers_start where 1=1
  141. <if test="customerCode !=null and customerCode !=''">
  142. and customers_code=#{customerCode}
  143. </if>
  144. GROUP BY customer_type
  145. </select>
  146. <select id="deleteCustomerStartByCustomerCode" parameterType="String" >
  147. delete from customers_start where 1=1
  148. <if test="customerCode !=null and customerCode !=''">
  149. and customers_code=#{customerCode}
  150. </if>
  151. </select>
  152. <!-- INSERT INTO customers_start (customers_code, customers_name, online_time,customer_type)
  153. SELECT t.mainkunnr,t.mainname1,t1.online_time,t1.customer_type FROM (
  154. SELECT s.mainkunnr,s.mainname1,s.kunnr,s.customer_type from (
  155. SELECT
  156. ar.*
  157. FROM
  158. customers_start cs
  159. LEFT JOIN ass_relcustomerinfo ar ON (cs.customers_code=ar.kunnr or cs.customers_code=ar.mainkunnr)
  160. WHERE ar.glfs != '开票方关联'
  161. GROUP BY kunnr
  162. ) s LEFT JOIN customers_start c ON s.mainkunnr = c.customers_code
  163. WHERE c.customers_code is null
  164. ) t LEFT JOIN customers_start t1 ON t.kunnr = t1.customers_code
  165. union all
  166. SELECT t.kunnr,t.name1,t1.online_time,t1.customer_type FROM (
  167. SELECT s.kunnr,s.name1,s.mainkunnr,s.customer_type from (
  168. SELECT
  169. ar.*
  170. FROM
  171. customers_start cs
  172. LEFT JOIN ass_relcustomerinfo ar ON (cs.customers_code=ar.kunnr or cs.customers_code=ar.mainkunnr)
  173. WHERE ar.glfs != '开票方关联'
  174. GROUP BY kunnr
  175. ) s LEFT JOIN customers_start c ON s.kunnr = c.customers_code
  176. WHERE c.customers_code is null
  177. ) t LEFT JOIN customers_start t1 ON t.mainkunnr = t1.customers_code-->
  178. <select id="selectAssRelCustomer" resultMap="AssRelcustomerinfoResult">
  179. <include refid="selectAssRelcustomerinfoVo"/>
  180. where customer_type is not null
  181. </select>
  182. <update id="updateAssRelcustomerinfo" parameterType="AssRelcustomerinfo">
  183. update ass_relcustomerinfo
  184. <trim prefix="SET" suffixOverrides=",">
  185. <if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
  186. <if test="createTime != null ">create_time = #{createTime},</if>
  187. <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
  188. <if test="updateTime != null ">update_time = #{updateTime},</if>
  189. <if test="isDelete != null ">is_delete = #{isDelete},</if>
  190. <if test="mainkunnr != null and mainkunnr != ''">mainkunnr = #{mainkunnr},</if>
  191. <if test="mainname1 != null and mainname1 != ''">mainname1 = #{mainname1},</if>
  192. <if test="kunnr != null and kunnr != ''">kunnr = #{kunnr},</if>
  193. <if test="name1 != null and name1 != ''">name1 = #{name1},</if>
  194. <if test="glfs != null and glfs != ''">glfs = #{glfs},</if>
  195. <if test="glsj != null ">glsj = #{glsj},</if>
  196. <if test="enddate != null ">enddate = #{enddate},</if>
  197. <if test="etlCreatetime != null ">ETL_createtime = #{etlCreatetime},</if>
  198. </trim>
  199. where id = #{id}
  200. </update>
  201. <delete id="deleteAssRelcustomerinfoById" parameterType="Long">
  202. delete from ass_relcustomerinfo where id = #{id}
  203. </delete>
  204. <delete id="deleteAssRelcustomerinfoByIds" parameterType="String">
  205. delete from ass_relcustomerinfo where id in
  206. <foreach item="id" collection="array" open="(" separator="," close=")">
  207. #{id}
  208. </foreach>
  209. </delete>
  210. <delete id="deleteAssRelcustomerinfoByGlfs" parameterType="String">
  211. delete from ass_relcustomerinfo where glfs =#{glfs}
  212. </delete>
  213. <delete id="deleteAssRelcustomerinfoByUserId" parameterType="String">
  214. delete from ass_relcustomerinfo where 1=1
  215. <if test="userId !=null and userId !='' ">
  216. and user_id =#{userId}
  217. </if>
  218. <if test="customerCode !=null and customerCode !='' ">
  219. and( kunnr =#{customerCode} or mainkunnr =#{customerCode})
  220. </if>
  221. and glfs='用户关联'
  222. </delete>
  223. <select id="selectCustomerName" resultType="java.lang.String">
  224. select customer_name from order_sales_sum_tuc_customer where 1=1
  225. <if test="customerId !=null and customerId !='' ">
  226. and customer_id=#{customerId}
  227. </if> LIMIT 1
  228. </select>
  229. <select id="selectCustomerNameAndCode" resultMap="AssRelcustomerinfoResult">
  230. select mainkunnr as mainkunnr,mainname1 as mainname1 FROM `ass_relcustomerinfo`
  231. UNION select kunnr as mainkunnr,name1 as mainname1 FROM `ass_relcustomerinfo`
  232. </select>
  233. </mapper>