|
|
@@ -38,13 +38,13 @@
|
|
|
|
|
|
<sql id="Base_Column_List">
|
|
|
id, firm_name, code, contacts, phone, legal_name, legal_phone, head, integral,
|
|
|
- balance, experience, member_level, reg_time, reg_source, org_code, city_code, detail_address,
|
|
|
- lat, lng, approval, approval_time, manager, remark, status, create_by, create_time,
|
|
|
+ balance, experience, member_level, reg_time, reg_source, org_code, city_code, detail_address,
|
|
|
+ lat, lng, approval, approval_time, manager, remark, status, create_by, create_time,
|
|
|
update_by, update_time, del_flag,city_name, website, business
|
|
|
</sql>
|
|
|
|
|
|
<select id="selectByKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
|
|
|
- select
|
|
|
+ select
|
|
|
<include refid="Base_Column_List" />
|
|
|
from kws_enterprise
|
|
|
where id = #{id,jdbcType=BIGINT}
|
|
|
@@ -688,4 +688,216 @@
|
|
|
and del_flag = 0
|
|
|
</update>
|
|
|
|
|
|
+ <select id="findEnterpriseIdsByUserRoleId" resultType="java.lang.Long">
|
|
|
+ SELECT id
|
|
|
+ from kws_enterprise
|
|
|
+ where del_flag = 0 and status = 0
|
|
|
+ <if test="userId != null">
|
|
|
+ and (manager = #{userId} or manager in (SELECT user_id
|
|
|
+ from kws_user_dept
|
|
|
+ where dept_id in (SELECT dept_id from kws_authority where role_id = #{roleId})))
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="findEnterpriseIdsByUserRoleIds" resultType="java.lang.Long">
|
|
|
+ SELECT id
|
|
|
+ from kws_enterprise
|
|
|
+ <where>
|
|
|
+ del_flag = 0
|
|
|
+ and status = 0
|
|
|
+ <if test="userId != null">
|
|
|
+ and (manager = #{userId} or manager in (SELECT user_id
|
|
|
+ from kws_user_dept
|
|
|
+ where dept_id in (SELECT dept_id
|
|
|
+ from kws_authority
|
|
|
+ <where>
|
|
|
+ status = 0
|
|
|
+ and del_flag = 0
|
|
|
+ <if test="roleIds != null and roleIds.size() != 0">
|
|
|
+ and role_id in
|
|
|
+ <foreach collection="roleIds" item="item" separator="," open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ )
|
|
|
+ )
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="findPojoAndManager" resultType="com.sckw.system.model.pojo.FindEntListPojo">
|
|
|
+ select tab.*,
|
|
|
+ case when tab.id in (select ent_id from kws_ent_dep) then '子单位' else '主单位' end entDept,
|
|
|
+ case when tab.status = 0 then '正常' else '冻结' end statusName
|
|
|
+ from
|
|
|
+ (
|
|
|
+ select a.id,
|
|
|
+ min(a.firm_name) firm_name,
|
|
|
+ min(a.code) code,
|
|
|
+ min(a.contacts) contacts,
|
|
|
+ min(a.phone) phone,
|
|
|
+ min(a.legal_name) legal_name,
|
|
|
+ min(a.legal_phone) legal_phone,
|
|
|
+ min(a.head) head,
|
|
|
+ min(a.integral) integral,
|
|
|
+ min(a.balance) balance,
|
|
|
+ min(a.experience) experience,
|
|
|
+ min(a.member_level) member_level,
|
|
|
+ min(a.reg_time) reg_time,
|
|
|
+ min(a.reg_source) reg_source,
|
|
|
+ min(a.org_code) org_code,
|
|
|
+ min(a.city_code) city_code,
|
|
|
+ min(a.detail_address) detail_address,
|
|
|
+ min(a.lat) lat,
|
|
|
+ min(a.lng) lng,
|
|
|
+ min(a.approval) approval,
|
|
|
+ min(a.approval_time) approval_time,
|
|
|
+ min(a.manager) manager,
|
|
|
+ min(a.remark) remark,
|
|
|
+ min(a.status) status,
|
|
|
+ min(a.create_by) create_by,
|
|
|
+ min(a.create_time) create_time,
|
|
|
+ min(a.update_by) update_by,
|
|
|
+ min(a.update_time) update_time,
|
|
|
+ min(a.del_flag) del_flag,
|
|
|
+ ifnull(GROUP_CONCAT(distinct b.type), '') type,
|
|
|
+ min(k.system_type) system_type,
|
|
|
+ min(k.name) createByName,
|
|
|
+ min(ku.name) updateByName,
|
|
|
+ min(d.id) pid,
|
|
|
+ min(d.firm_name) pEntName
|
|
|
+ from kws_enterprise a
|
|
|
+ left join kws_user k on a.create_by = k.id
|
|
|
+ left join kws_user ku on a.update_by = ku.id
|
|
|
+ left join kws_ent_type b on a.id = b.ent_id and b.del_flag = 0
|
|
|
+ <if test="dto.approval == null or (dto.approval != null and dto.approval != 2)">
|
|
|
+ and b.status != 1
|
|
|
+ </if>
|
|
|
+ left join kws_ent_dep c on a.id = c.ent_id
|
|
|
+ left join kws_enterprise d on c.ent_pid = d.id
|
|
|
+ where a.del_flag = 0
|
|
|
+ <if test="dto.typeList != null and dto.typeList.size() > 0">
|
|
|
+ and exists (select 1
|
|
|
+ from kws_ent_type kt
|
|
|
+ where a.id = kt.ent_id
|
|
|
+ and kt.del_flag = 0
|
|
|
+ and kt.type in
|
|
|
+ <foreach collection="dto.typeList" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ <choose>
|
|
|
+ <when test="dto.approval != null and dto.approval == 3">
|
|
|
+ and a.approval in (3,4)
|
|
|
+ </when>
|
|
|
+ <when test="dto.approval != null and dto.approval != 3">
|
|
|
+ and a.approval = #{dto.approval}
|
|
|
+ </when>
|
|
|
+ </choose>
|
|
|
+ <if test="dto.customer != null and dto.customer == 1">
|
|
|
+ and a.approval in (1, 4)
|
|
|
+ </if>
|
|
|
+ <if test="dto.keywords != null">
|
|
|
+ and (a.contacts like concat('%', #{dto.keywords}, '%') or a.phone like concat('%', #{dto.keywords}, '%') or a.firm_name like concat('%', #{dto.keywords}, '%'))
|
|
|
+ </if>
|
|
|
+ <if test="dto.startTime != null">
|
|
|
+ and a.reg_time >= #{dto.startTime}
|
|
|
+ </if>
|
|
|
+ <if test="dto.endTime != null">
|
|
|
+ and a.reg_time <= #{dto.endTime}
|
|
|
+ </if>
|
|
|
+ <if test="dto.approvalStartTime != null">
|
|
|
+ and a.approval_time >= #{dto.approvalStartTime}
|
|
|
+ </if>
|
|
|
+ <if test="dto.approvalEndTime != null">
|
|
|
+ and a.approval_time < date_add(#{dto.approvalEndTime}, INTERVAL 1 DAY)
|
|
|
+ </if>
|
|
|
+ <if test="dto.status != null and dto.status != ''">
|
|
|
+ and a.status = #{dto.status}
|
|
|
+ </if>
|
|
|
+ <if test="dto.entryType != null and dto.entryType == 1">
|
|
|
+ and k.system_type = 2
|
|
|
+ </if>
|
|
|
+ <if test="dto.entryType != null and dto.entryType == 2">
|
|
|
+ and k.system_type = 1
|
|
|
+ </if>
|
|
|
+ <if test="dto.idList != null and dto.idList.size() > 0">
|
|
|
+ and a.id in
|
|
|
+ <foreach collection="dto.idList" item="item" separator="," open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <choose>
|
|
|
+ <when test="dto.entDept != null and dto.entDept == 0">
|
|
|
+ and not exists (
|
|
|
+ select 1
|
|
|
+ from kws_ent_dep dep
|
|
|
+ where a.id = dep.ent_id
|
|
|
+ <if test="dto.entId != null">
|
|
|
+ and dep.ent_pid = #{dto.entId}
|
|
|
+ </if>
|
|
|
+ )
|
|
|
+ </when>
|
|
|
+ <when test="dto.entDept != null and dto.entDept == 1">
|
|
|
+ and exists (
|
|
|
+ select 1 from kws_ent_dep dep
|
|
|
+ where a.id = dep.ent_id
|
|
|
+ <if test="dto.entId != null">
|
|
|
+ and dep.ent_pid = #{dto.entId}
|
|
|
+ </if>)
|
|
|
+ </when>
|
|
|
+ </choose>
|
|
|
+ group by a.id
|
|
|
+ ) tab
|
|
|
+ where tab.id is not null
|
|
|
+ order by tab.update_time desc
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="findEnterpriseIdsByUserIdAndUserRoleIds" resultType="java.lang.Long">
|
|
|
+ SELECT id
|
|
|
+ from kws_enterprise
|
|
|
+ <where>
|
|
|
+ del_flag = 0
|
|
|
+ and status = 0
|
|
|
+ <if test="userIds != null and userIds.size() != 0">
|
|
|
+ and ( (manager in
|
|
|
+ <foreach collection="userIds" item="item" separator="," open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ ) or manager in (SELECT user_id
|
|
|
+ from kws_user_dept
|
|
|
+ where dept_id in (SELECT dept_id
|
|
|
+ from kws_authority
|
|
|
+ <where>
|
|
|
+ status = 0
|
|
|
+ and del_flag = 0
|
|
|
+ <if test="roleIds != null and roleIds.size() != 0">
|
|
|
+ and role_id in
|
|
|
+ <foreach collection="roleIds" item="item" separator="," open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ )
|
|
|
+ )
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="findEnterpriseIdsByUserIds" resultType="java.lang.Long">
|
|
|
+ SELECT id
|
|
|
+ from kws_enterprise
|
|
|
+ where status = 0
|
|
|
+ and del_flag = 0
|
|
|
+ <if test="userIds != null and userIds.size() != 0">
|
|
|
+ and manager in
|
|
|
+ <foreach collection="userIds" separator="," close=")" open="(" item="item">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
</mapper>
|