| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609 |
- <?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.sckw.system.dao.KwsEnterpriseDao">
- <resultMap id="BaseResultMap" type="com.sckw.system.model.KwsEnterprise">
- <id column="id" jdbcType="BIGINT" property="id" />
- <result column="firm_name" jdbcType="VARCHAR" property="firmName" />
- <result column="code" jdbcType="VARCHAR" property="code" />
- <result column="contacts" jdbcType="VARCHAR" property="contacts" />
- <result column="phone" jdbcType="VARCHAR" property="phone" />
- <result column="legal_name" jdbcType="VARCHAR" property="legalName" />
- <result column="legal_phone" jdbcType="VARCHAR" property="legalPhone" />
- <result column="head" jdbcType="VARCHAR" property="head" />
- <result column="integral" jdbcType="INTEGER" property="integral" />
- <result column="balance" jdbcType="DECIMAL" property="balance" />
- <result column="experience" jdbcType="INTEGER" property="experience" />
- <result column="member_level" jdbcType="INTEGER" property="memberLevel" />
- <result column="reg_time" jdbcType="TIMESTAMP" property="regTime" />
- <result column="reg_source" jdbcType="VARCHAR" property="regSource" />
- <result column="org_code" jdbcType="VARCHAR" property="orgCode" />
- <result column="city_code" jdbcType="INTEGER" property="cityCode" />
- <result column="detail_address" jdbcType="VARCHAR" property="detailAddress" />
- <result column="city_name" jdbcType="VARCHAR" property="cityName" />
- <result column="lat" jdbcType="VARCHAR" property="lat" />
- <result column="lng" jdbcType="VARCHAR" property="lng" />
- <result column="approval" jdbcType="INTEGER" property="approval" />
- <result column="approval_time" jdbcType="TIMESTAMP" property="approvalTime" />
- <result column="manager" jdbcType="BIGINT" property="manager" />
- <result column="remark" jdbcType="VARCHAR" property="remark" />
- <result column="status" jdbcType="INTEGER" property="status" />
- <result column="create_by" jdbcType="BIGINT" property="createBy" />
- <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
- <result column="update_by" jdbcType="BIGINT" property="updateBy" />
- <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
- <result column="del_flag" jdbcType="INTEGER" property="delFlag" />
- <result column="website" jdbcType="VARCHAR" property="website" />
- <result column="business" jdbcType="VARCHAR" property="business" />
- </resultMap>
- <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,
- update_by, update_time, del_flag,city_name, website, business
- </sql>
- <select id="selectByKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
- select
- <include refid="Base_Column_List" />
- from kws_enterprise
- where id = #{id,jdbcType=BIGINT}
- </select>
- <select id="findPojo" resultType="com.sckw.system.model.pojo.FindEntListPojo" parameterType="com.sckw.system.model.pojo.FindPojoParam">
- 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
- 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.typeList != null and dto.typeList.size() > 0">and b.type in
- <foreach collection="dto.typeList" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- where a.del_flag = 0
- <if test="dto.approval != null">
- and a.approval = #{dto.approval}
- </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.update_time >= #{dto.startTime}
- </if>
- <if test="dto.endTime != null">
- and a.update_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>
- <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.create_time desc
- </select>
- <select id="findList" resultType="com.sckw.system.model.vo.res.FindEntListResVo" parameterType="com.sckw.system.model.vo.req.FindListReqVo">
- select a.*,
- b.id userId,
- b.account,
- b.name
- from kws_enterprise a
- left join kws_user b on a.phone = b.account and b.del_flag = 0
- where a.del_flag = 0
- <if test="approval != null">
- and a.approval = #{approval}
- </if>
- <if test="entName != null and entName != ''">
- and a.firm_name like concat('%', #{entName}, '%')
- </if>
- <if test="entType != null">
- and exists (select 1 from kws_ent_type b where a.id = b.ent_id and b.type = #{entType})
- </if>
- order by a.create_time
- </select>
- <select id="findByUserId" resultType="com.sckw.system.model.KwsEnterprise">
- select distinct a.*
- from kws_enterprise a
- inner join kws_dept b on a.id = b.ent_id
- inner join kws_user_dept c on b.id = c.dept_id
- inner join kws_user d on c.user_id = d.id
- where d.id = #{id}
- and a.del_flag = 0
- and b.del_flag = 0
- and c.del_flag = 0
- and d.del_flag = 0
- and a.status = 0
- and b.status = 0
- and c.status = 0
- and d.status = 0
- </select>
- <select id="selectByKeys" resultType="com.sckw.system.model.KwsEnterprise">
- select
- <include refid="Base_Column_List" />
- from kws_enterprise
- where del_flag = 0
- and approval = 1
- <if test="list != null and list.size() > 0">
- and id in
- <foreach collection="list" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- </select>
- <select id="findUserByEntIds" resultType="com.sckw.system.model.pojo.FindEntUserPojo">
- select distinct a.id entId,
- a.firm_name entName,
- d.id userId,
- d.name,
- d.account,
- d.phone
- from kws_enterprise a
- left join kws_dept b on a.id = b.ent_id
- left join kws_user_dept c on b.id = c.dept_id
- left join kws_user d on c.user_id = d.id
- where a.del_flag = 0
- and b.del_flag = 0
- and c.del_flag = 0
- and d.del_flag = 0
- and a.id in
- <foreach collection="list" separator="," open="(" close=")" item="item">
- #{item}
- </foreach>
- </select>
- <select id="findManageInfoByEntId" resultType="com.sckw.system.model.pojo.FindManagePojo">
- select distinct d.id userId,
- b.id deptId,
- f.id roleId
- from kws_enterprise a
- left join kws_dept b on a.id = b.ent_id
- left join kws_user_dept c on b.id = c.dept_id
- left join kws_user d on c.user_id = d.id
- left join kws_user_role e on d.id = e.user_id
- left join kws_role f on e.role_id = f.id
- where a.del_flag = 0
- and b.del_flag = 0
- and c.del_flag = 0
- and d.del_flag = 0
- and e.del_flag = 0
- and f.del_flag = 0
- and d.is_main = 1
- and d.system_type = 2
- and a.id = #{entId}
- </select>
- <select id="findManageInfoByEntIdBeforeApproval" resultType="com.sckw.system.model.pojo.FindManagePojo">
- select distinct d.id userId,
- f.id roleId
- from kws_enterprise a
- left join kws_dept b on a.id = b.ent_id
- LEFT JOIN kws_user d ON a.phone = d.account
- left join kws_role f on b.id = f.dept_id
- where a.del_flag = 0
- and b.del_flag = 0
- and d.del_flag = 0
- and f.del_flag = 0
- and d.is_main = 1
- and d.system_type = 2
- and a.id = #{entId}
- </select>
- <select id="queryEntByName" resultType="com.sckw.system.model.KwsEnterprise">
- select * from kws_enterprise where firm_name like concat('%', #{entName}, '%') and del_flag = 0
- </select>
- <select id="checkEntRepeat" resultType="com.sckw.system.model.KwsEnterprise">
- select * from kws_enterprise where (
- 1 = 1
- <if test="entName != null and entName != ''">
- or firm_name = #{entName}
- </if>
- <if test="phone != null and phone != ''">
- or phone = #{phone}
- </if>
- ) and del_flag = 0 and approval in (1,3,4)
- </select>
- <select id="selectAllByKeys" resultType="com.sckw.system.model.KwsEnterprise">
- select
- <include refid="Base_Column_List" />
- from kws_enterprise
- where del_flag = 0
- <if test="list != null and list.size() > 0">
- and id in
- <foreach collection="list" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- </select>
- <select id="queryEntInfoByCityCodeAndEntTypesWithPage" resultType="com.sckw.system.model.KwsEnterprise">
- SELECT a.*
- FROM kws_enterprise a
- LEFT JOIN sys_area b ON a.city_code = b.CODE
- where 1 = 1
- <if test="cityCode != null">
- and (b.code = #{cityCode} or b.province_code = #{cityCode} or b.pcode = #{cityCode})
- </if>
- <if test="entIdList != null and entIdList.size() > 0">
- and a.id in
- <foreach collection="entIdList" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- and exists (select 1
- from kws_ent_type k
- where a.id = k.ent_id
- and k.type in
- <foreach collection="entTypeList" open="(" close=")" separator="," item="item">
- #{item}
- </foreach>
- )
- </select>
- <insert id="insert" parameterType="com.sckw.system.model.KwsEnterprise">
- insert into kws_enterprise
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="id != null">
- id,
- </if>
- <if test="firmName != null">
- firm_name,
- </if>
- <if test="code != null">
- code,
- </if>
- <if test="contacts != null">
- contacts,
- </if>
- <if test="phone != null">
- phone,
- </if>
- <if test="legalName != null">
- legal_name,
- </if>
- <if test="legalPhone != null">
- legal_phone,
- </if>
- <if test="head != null">
- head,
- </if>
- <if test="integral != null">
- integral,
- </if>
- <if test="balance != null">
- balance,
- </if>
- <if test="experience != null">
- experience,
- </if>
- <if test="memberLevel != null">
- member_level,
- </if>
- <if test="regTime != null">
- reg_time,
- </if>
- <if test="regSource != null">
- reg_source,
- </if>
- <if test="orgCode != null">
- org_code,
- </if>
- <if test="cityCode != null">
- city_code,
- </if>
- <if test="detailAddress != null">
- detail_address,
- </if>
- <if test="lat != null">
- lat,
- </if>
- <if test="lng != null">
- lng,
- </if>
- <if test="approval != null">
- approval,
- </if>
- <if test="approvalTime != null">
- approval_time,
- </if>
- <if test="manager != null">
- manager,
- </if>
- <if test="remark != null">
- remark,
- </if>
- <if test="status != null">
- status,
- </if>
- <if test="createBy != null">
- create_by,
- </if>
- <if test="createTime != null">
- create_time,
- </if>
- <if test="updateBy != null">
- update_by,
- </if>
- <if test="updateTime != null">
- update_time,
- </if>
- <if test="delFlag != null">
- del_flag,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="id != null">
- #{id,jdbcType=BIGINT},
- </if>
- <if test="firmName != null">
- #{firmName,jdbcType=VARCHAR},
- </if>
- <if test="code != null">
- #{code,jdbcType=VARCHAR},
- </if>
- <if test="contacts != null">
- #{contacts,jdbcType=VARCHAR},
- </if>
- <if test="phone != null">
- #{phone,jdbcType=VARCHAR},
- </if>
- <if test="legalName != null">
- #{legalName,jdbcType=VARCHAR},
- </if>
- <if test="legalPhone != null">
- #{legalPhone,jdbcType=VARCHAR},
- </if>
- <if test="head != null">
- #{head,jdbcType=VARCHAR},
- </if>
- <if test="integral != null">
- #{integral,jdbcType=INTEGER},
- </if>
- <if test="balance != null">
- #{balance,jdbcType=DECIMAL},
- </if>
- <if test="experience != null">
- #{experience,jdbcType=INTEGER},
- </if>
- <if test="memberLevel != null">
- #{memberLevel,jdbcType=INTEGER},
- </if>
- <if test="regTime != null">
- #{regTime,jdbcType=TIMESTAMP},
- </if>
- <if test="regSource != null">
- #{regSource,jdbcType=VARCHAR},
- </if>
- <if test="orgCode != null">
- #{orgCode,jdbcType=VARCHAR},
- </if>
- <if test="cityCode != null">
- #{cityCode,jdbcType=INTEGER},
- </if>
- <if test="detailAddress != null">
- #{detailAddress,jdbcType=VARCHAR},
- </if>
- <if test="lat != null">
- #{lat,jdbcType=VARCHAR},
- </if>
- <if test="lng != null">
- #{lng,jdbcType=VARCHAR},
- </if>
- <if test="approval != null">
- #{approval,jdbcType=INTEGER},
- </if>
- <if test="approvalTime != null">
- #{approvalTime,jdbcType=TIMESTAMP},
- </if>
- <if test="manager != null">
- #{manager,jdbcType=BIGINT},
- </if>
- <if test="remark != null">
- #{remark,jdbcType=VARCHAR},
- </if>
- <if test="status != null">
- #{status,jdbcType=INTEGER},
- </if>
- <if test="createBy != null">
- #{createBy,jdbcType=BIGINT},
- </if>
- <if test="createTime != null">
- #{createTime,jdbcType=TIMESTAMP},
- </if>
- <if test="updateBy != null">
- #{updateBy,jdbcType=BIGINT},
- </if>
- <if test="updateTime != null">
- #{updateTime,jdbcType=TIMESTAMP},
- </if>
- <if test="delFlag != null">
- #{delFlag,jdbcType=INTEGER},
- </if>
- </trim>
- </insert>
- <update id="update" parameterType="com.sckw.system.model.KwsEnterprise">
- update kws_enterprise
- <set>
- <if test="firmName != null">
- firm_name = #{firmName,jdbcType=VARCHAR},
- </if>
- <if test="code != null">
- code = #{code,jdbcType=VARCHAR},
- </if>
- <if test="contacts != null">
- contacts = #{contacts,jdbcType=VARCHAR},
- </if>
- <if test="phone != null">
- phone = #{phone,jdbcType=VARCHAR},
- </if>
- <if test="legalName != null">
- legal_name = #{legalName,jdbcType=VARCHAR},
- </if>
- <if test="legalPhone != null">
- legal_phone = #{legalPhone,jdbcType=VARCHAR},
- </if>
- <if test="head != null">
- head = #{head,jdbcType=VARCHAR},
- </if>
- <if test="integral != null">
- integral = #{integral,jdbcType=INTEGER},
- </if>
- <if test="balance != null">
- balance = #{balance,jdbcType=DECIMAL},
- </if>
- <if test="experience != null">
- experience = #{experience,jdbcType=INTEGER},
- </if>
- <if test="memberLevel != null">
- member_level = #{memberLevel,jdbcType=INTEGER},
- </if>
- <if test="regTime != null">
- reg_time = #{regTime,jdbcType=TIMESTAMP},
- </if>
- <if test="regSource != null">
- reg_source = #{regSource,jdbcType=VARCHAR},
- </if>
- <if test="orgCode != null">
- org_code = #{orgCode,jdbcType=VARCHAR},
- </if>
- <if test="cityCode != null">
- city_code = #{cityCode,jdbcType=INTEGER},
- </if>
- <if test="cityName != null">
- city_name = #{cityName,jdbcType=VARCHAR},
- </if>
- <if test="detailAddress != null">
- detail_address = #{detailAddress,jdbcType=VARCHAR},
- </if>
- <if test="lat != null">
- lat = #{lat,jdbcType=VARCHAR},
- </if>
- <if test="lng != null">
- lng = #{lng,jdbcType=VARCHAR},
- </if>
- <if test="approval != null">
- approval = #{approval,jdbcType=INTEGER},
- </if>
- <if test="approvalTime != null">
- approval_time = #{approvalTime,jdbcType=TIMESTAMP},
- </if>
- <if test="manager != null">
- manager = #{manager,jdbcType=BIGINT},
- </if>
- <if test="remark != null">
- remark = #{remark,jdbcType=VARCHAR},
- </if>
- <if test="status != null">
- status = #{status,jdbcType=INTEGER},
- </if>
- <if test="createBy != null">
- create_by = #{createBy,jdbcType=BIGINT},
- </if>
- <if test="createTime != null">
- create_time = #{createTime,jdbcType=TIMESTAMP},
- </if>
- <if test="updateBy != null">
- update_by = #{updateBy,jdbcType=BIGINT},
- </if>
- <if test="updateTime != null">
- update_time = #{updateTime,jdbcType=TIMESTAMP},
- </if>
- <if test="delFlag != null">
- del_flag = #{delFlag,jdbcType=INTEGER},
- </if>
- <if test="website != null">
- website = #{website,jdbcType=VARCHAR},
- </if>
- <if test="business != null">
- business = #{business,jdbcType=VARCHAR},
- </if>
- </set>
- where id = #{id,jdbcType=BIGINT}
- </update>
- <update id="approval">
- update kws_enterprise
- set approval = #{approval},
- approval_time = now(),
- remark = #{remark}
- where id = #{id,jdbcType=BIGINT}
- and approval in (3, 4)
- and del_flag = 0
- </update>
- </mapper>
|