You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
137 lines
4.8 KiB
137 lines
4.8 KiB
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
|
<mapper namespace="com.epmet.dao.CustomerDao">
|
|
|
|
<resultMap type="com.epmet.entity.CustomerEntity" id="customerMap">
|
|
<result property="id" column="ID"/>
|
|
<result property="customerName" column="CUSTOMER_NAME"/>
|
|
<result property="title" column="TITLE"/>
|
|
<result property="organizationNumber" column="ORGANIZATION_NUMBER"/>
|
|
<result property="organizationImg" column="ORGANIZATION_IMG"/>
|
|
<result property="validityTime" column="VALIDITY_TIME"/>
|
|
<result property="customerAdmin" column="CUSTOMER_ADMIN"/>
|
|
<result property="customerPassword" column="CUSTOMER_PASSWORD"/>
|
|
<result property="organizationLevel" column="ORGANIZATION_LEVEL"/>
|
|
<result property="logo" column="LOGO"/>
|
|
<result property="delFlag" column="DEL_FLAG"/>
|
|
<result property="revision" column="REVISION"/>
|
|
<result property="createdBy" column="CREATED_BY"/>
|
|
<result property="createdTime" column="CREATED_TIME"/>
|
|
<result property="updatedBy" column="UPDATED_BY"/>
|
|
<result property="updatedTime" column="UPDATED_TIME"/>
|
|
</resultMap>
|
|
|
|
<!-- 运营端-获取有效客户列表 (未删除+有效期内的,按照客户名称排序 )-->
|
|
<select id="selectListValidCustomerResultDTO" resultType="com.epmet.dto.result.ValidCustomerResultDTO">
|
|
SELECT c.id AS CUSTOMER_ID,
|
|
c.CUSTOMER_NAME,
|
|
CASE WHEN c.LOGO IS NULL THEN '' ELSE c.LOGO END AS LOGO
|
|
FROM
|
|
customer c
|
|
WHERE
|
|
c.DEL_FLAG = '0'
|
|
AND c.VALIDITY_TIME > NOW()
|
|
ORDER BY
|
|
CONVERT ( c.CUSTOMER_NAME USING gbk ) ASC
|
|
</select>
|
|
|
|
<!-- 根据客户id查询客户信息 -->
|
|
<select id="selectListByIds" parameterType="map" resultType="com.epmet.dto.CustomerDTO">
|
|
SELECT
|
|
*
|
|
FROM
|
|
customer c
|
|
WHERE
|
|
c.DEL_FLAG = '0'
|
|
AND c.id IN
|
|
<foreach item="customerId" collection="customerIdList" open="(" separator="," close=")">
|
|
#{customerId}
|
|
</foreach>
|
|
</select>
|
|
|
|
<!--根据名字查询客户-->
|
|
<select id="selectByCustomerName" resultType="com.epmet.dto.CustomerDTO">
|
|
SELECT *
|
|
FROM customer
|
|
WHERE CUSTOMER_NAME = #{customerName}
|
|
</select>
|
|
|
|
<select id="selectCustomerList" resultType="com.epmet.dto.result.CustomerResultDTO">
|
|
SELECT
|
|
id AS "customerId",
|
|
customer_name AS "customerName",
|
|
IFNULL(logo,"") AS "logo"
|
|
FROM
|
|
customer
|
|
WHERE
|
|
del_flag = '0'
|
|
<if test='customerName != "" and customerName != null'>
|
|
AND customer_name LIKE concat('%', trim(#{customerName}), '%')
|
|
</if>
|
|
ORDER BY
|
|
created_time DESC
|
|
</select>
|
|
|
|
<select id="getAllList" resultMap="customerMap">
|
|
SELECT
|
|
*
|
|
FROM customer
|
|
WHERE
|
|
del_flag = '0'
|
|
</select>
|
|
|
|
<!-- 查询客户下可以创建网格的最大数 -->
|
|
<select id="getGridCount" resultType="com.epmet.dto.result.GridCountResultDTO">
|
|
SELECT
|
|
IFNULL( grid_number, 0 ) AS gridCount
|
|
FROM
|
|
customer
|
|
WHERE
|
|
del_flag = 0
|
|
AND id = #{customerId}
|
|
</select>
|
|
|
|
<!-- 根据客户Id查询客户基本信息 -->
|
|
<select id="selectCustomerBasicInfo" resultType="com.epmet.dto.result.CustomerInfoResultDTO">
|
|
SELECT
|
|
id AS customerId,
|
|
customer_name AS customerName,
|
|
IFNULL( grid_number, 0 ) AS maxGridNumber,
|
|
validity_time AS validityTime
|
|
FROM
|
|
customer
|
|
WHERE
|
|
del_flag = 0
|
|
AND id = #{customerId}
|
|
</select>
|
|
|
|
<select id="selectAllCustomerList" resultType="com.epmet.dto.result.CustomerListResultDTO">
|
|
SELECT
|
|
id AS "customerId",
|
|
customer_name,
|
|
title,
|
|
validity_time,
|
|
organization_level,
|
|
logo,
|
|
grid_number
|
|
FROM customer
|
|
WHERE
|
|
del_flag = '0'
|
|
<if test='customerName != "" and customerName != null'>
|
|
AND customer_name LIKE concat('%', trim(#{customerName}), '%')
|
|
</if>
|
|
ORDER BY
|
|
created_time DESC
|
|
</select>
|
|
|
|
<select id="getExternalAndParentCustomerId" resultType="String">
|
|
SELECT
|
|
CR.PARENT_CUSTOMER_ID AS rootCustomerId
|
|
FROM customer_relation cr
|
|
WHERE cr.DEL_FLAG = '0'
|
|
AND cr.CUSTOMER_ID = #{customerId,jdbcType=VARCHAR}
|
|
AND cr.PARENT_CUSTOMER_ID != '0'
|
|
AND cr.CUSTOMER_TYPE = 'external'
|
|
</select>
|
|
</mapper>
|
|
|