Files
shz-backend/ruoyi-bussiness/src/main/resources/mapper/app/CompanyMapper.xml
francis-fh 5f33be65ca 11
2026-07-29 19:35:53 +08:00

337 lines
19 KiB
XML

<?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.ruoyi.cms.mapper.CompanyMapper">
<resultMap type="Company" id="CompanyResult">
<result property="companyId" column="company_id" />
<result property="name" column="name" />
<result property="location" column="location" />
<result property="industry" column="industry" />
<result property="scale" column="scale" />
<result property="code" column="code" />
<result property="delFlag" column="del_flag" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<result property="description" column="description" />
<result property="nature" column="nature" />
<result property="companyNature" column="company_nature" />
<result property="totalRecruitment" column="total_recruitment" />
<result property="userId" column="user_id" />
<result property="businessLicenseUrl" column="business_license_url" />
<result property="idCardPictureUrl" column="id_card_picture_url" />
<result property="idCardPictureBackUrl" column="id_card_picture_back_url" />
<result property="powerOfAttorneyUrl" column="power_of_attorneyUrl" />
<result property="contactPerson" column="contact_person" />
<result property="contactPersonPhone" column="contact_person_phone" />
<result property="status" column="status" />
<result property="notPassReason" column="not_pass_reason" />
<result property="registeredAddress" column="registered_address" />
<result property="isAbnormal" column="is_abnormal" />
<result property="enterpriseType" column="enterprise_type" />
<result property="isImpCompany" column="is_imp_company" />
<result property="impCompanyType" column="imp_company_type" />
<result property="legalPerson" column="legal_person" />
<result property="legalIdCard" column="legal_id_card" />
<result property="legalPhone" column="legal_phone" />
<result property="companyStatus" column="company_status" />
<result property="isHrs" column="is_hrs" />
<result property="lcUserid" column="lc_userid" />
<result property="missedOutdoorFairCount" column="missed_outdoor_fair_count" />
<collection property="companyContactList" ofType="com.ruoyi.common.core.domain.entity.CompanyContact"
select="selectCompanyContactsById"
column="company_id"/>
</resultMap>
<resultMap type="com.ruoyi.common.core.domain.entity.CompanyContact" id="CompanyContactResult">
<result property="id" column="id" />
<result property="companyId" column="company_id" />
<result property="contactPerson" column="contact_person"/>
<result property="contactPersonPhone" column="contact_person_phone"/>
</resultMap>
<select id="selectCompanyContactsById" resultMap="CompanyContactResult">
select id, company_id, contact_person, contact_person_phone
from company_contact
where company_id = #{companyId}
and del_flag = '0'
</select>
<sql id="selectCompanyVo">
select company_id, name, location, industry, scale, del_flag, create_by, create_time, update_by, update_time, remark,code,description,nature,company_nature,total_recruitment,registered_address,contact_person,contact_person_phone,is_abnormal,not_pass_reason,status,case when status='2' then update_time else null end reject_time,is_imp_company,imp_company_type,enterprise_type,legal_person,legal_id_card,legal_phone,is_hrs,
(select count(1)
from shz.fair_company fc
join shz.cms_outdoor_fair f on f.id = fc.job_fair_id and f.del_flag = '0'
left join shz.cms_outdoor_fair_company_attendance a
on a.fair_id = fc.job_fair_id and a.company_id = fc.company_id and a.del_flag = '0'
where fc.company_id = cp.company_id
and fc.del_flag = '0'
and fc.review_status = '1'
and f.end_time &lt; CURRENT_TIMESTAMP
and coalesce(a.attendance_status, '0') &lt;&gt; '1') as missed_outdoor_fair_count
from company cp
</sql>
<sql id="companyIndustryFilter">
<if test="industry != null and industry != ''">
<choose>
<when test="industry == '食品产业' or industry == '食品加工'">
and (
industry in ('食品加工', '食品产业', '绿色有机食品', '食品/饮料/酒水')
or industry like '%食品%'
or industry like '%饮料%'
or industry like '%酒%'
)
</when>
<when test="industry == '纺织服装'">
and (
industry = '纺织服装'
or industry like '%纺织%'
or industry like '%服装%'
)
</when>
<when test="industry == '装备制造'">
and (
industry = '装备制造'
or industry like '%装备%'
or industry like '%制造%'
or industry like '%机械%'
or industry like '%设备%'
)
</when>
<when test="industry == '其他'">
and (
industry is null
or (
coalesce(industry, '') not in ('食品加工', '食品产业', '绿色有机食品', '食品/饮料/酒水', '纺织服装', '装备制造')
and coalesce(industry, '') not like '%食品%'
and coalesce(industry, '') not like '%饮料%'
and coalesce(industry, '') not like '%酒%'
and coalesce(industry, '') not like '%纺织%'
and coalesce(industry, '') not like '%服装%'
and coalesce(industry, '') not like '%装备%'
and coalesce(industry, '') not like '%制造%'
and coalesce(industry, '') not like '%机械%'
and coalesce(industry, '') not like '%设备%'
)
)
</when>
<otherwise>
and industry = #{industry}
</otherwise>
</choose>
</if>
</sql>
<insert id="batchInsert" parameterType="java.util.List">
INSERT INTO company (
name, location, industry, scale, code, description, nature, company_nature,
create_by, create_time, del_flag
) VALUES
<foreach collection="list" item="company" separator=",">
(
#{company.name}, #{company.location}, #{company.industry}, #{company.scale},
#{company.code}, #{company.description}, #{company.nature}, #{company.companyNature},
#{company.createBy}, #{company.createTime}, #{company.delFlag}
)
</foreach>
</insert>
<update id="updateJobCountOfCompany">
UPDATE company c
SET TOTAL_RECRUITMENT = (
SELECT COUNT(*)
FROM job j
WHERE j.company_id = c.company_id
)
</update>
<select id="selectCompanyList" parameterType="CompanySearch" resultMap="CompanyResult">
select cp.company_id, cp.name, cp.location, cp.industry, cp.scale, cp.del_flag, cp.create_by, cp.create_time, cp.update_by, cp.update_time, cp.remark,
cp.code,cp.description,cp.nature,cp.company_nature,cp.total_recruitment,cp.registered_address,cp.contact_person,cp.contact_person_phone,cp.is_abnormal,
cp.not_pass_reason,cp.status,case when cp.status='2' then cp.update_time else null end reject_time,cp.is_imp_company,cp.imp_company_type,cp.enterprise_type,
cp.legal_person,cp.legal_id_card,cp.legal_phone,cp.is_hrs,
(select count(1)
from shz.fair_company fc
join shz.cms_outdoor_fair f on f.id = fc.job_fair_id and f.del_flag = '0'
left join shz.cms_outdoor_fair_company_attendance a
on a.fair_id = fc.job_fair_id and a.company_id = fc.company_id and a.del_flag = '0'
where fc.company_id = cp.company_id
and fc.del_flag = '0'
and fc.review_status = '1'
and f.end_time &lt; CURRENT_TIMESTAMP
and coalesce(a.attendance_status, '0') &lt;&gt; '1') as missed_outdoor_fair_count
from company cp
<where> cp.del_flag = '0'
<if test="name != null and name != ''"> and cp.name like concat('%', cast(#{name, jdbcType=VARCHAR} as varchar), '%')</if>
<if test="location != null and location != ''"> and cp.location = #{location}</if>
<include refid="companyIndustryFilter"/>
<if test="scale != null and scale != ''"> and cp.scale = #{scale}</if>
<if test="nature != null and nature != ''"> and cp.nature = #{nature}</if>
<if test="companyNature != null and companyNature != ''"> and cp.company_nature = #{companyNature}</if>
<if test="code != null and code != ''"> and cp.code = #{code}</if>
<if test="status != null and status != ''"> and cp.status = #{status}</if>
<if test="companyId != null and companyId != ''"> and cp.company_id = #{companyId}</if>
<if test="userId != null"> and cp.user_id = #{userId}</if>
<if test="isHrs != null and isHrs != ''"> and cp.is_hrs = #{isHrs}</if>
<if test="startDate != null and startDate != ''">
and cp.create_time >= #{startDate}
</if>
<if test="endDate != null and endDate != ''">
and cp.create_time &lt;= #{endDate}
</if>
<if test="missedOutdoorFairOnly == true">
and exists (
select 1
from shz.fair_company fc
join shz.cms_outdoor_fair f on f.id = fc.job_fair_id and f.del_flag = '0'
left join shz.cms_outdoor_fair_company_attendance a
on a.fair_id = fc.job_fair_id and a.company_id = fc.company_id and a.del_flag = '0'
where fc.company_id = cp.company_id
and fc.del_flag = '0'
and fc.review_status = '1'
and f.end_time &lt; CURRENT_TIMESTAMP
and coalesce(a.attendance_status, '0') &lt;&gt; '1'
)
</if>
</where>
</select>
<select id="label" resultMap="CompanyResult">
SELECT * FROM COMPANY WHERE COMPANY_ID IN (select -1
<if test="companyNature!=null and companyNature!=''">
UNION
SELECT COMPANY_ID FROM COMPANY WHERE company_nature = #{companyNature}
</if>
<if test="targ!=null and targ!=''">
UNION
SELECT company_id FROM COMPANY_LABEL WHERE dict_value = #{targ}
</if>)
<if test="companyName != null and companyName != ''"> and name like concat('%',#{companyName},'%')</if>
</select>
<select id="selectLikeCompanyList" parameterType="Company" resultMap="CompanyResult">
<include refid="selectCompanyVo"/>
<where> del_flag = '0'
<if test="name != null and name != ''"> and name like concat('%', cast(#{name, jdbcType=VARCHAR} as varchar), '%')</if>
<if test="location != null and location != ''"> and location = #{location}</if>
<include refid="companyIndustryFilter"/>
<if test="scale != null and scale != ''"> and scale = #{scale}</if>
<if test="nature != null and nature != ''"> and nature = #{nature}</if>
<if test="companyNature != null and companyNature != ''"> and company_nature = #{companyNature}</if>
<if test="code != null and code != ''"> and code = #{code}</if>
<if test="status != null and status != ''"> and status = #{status}</if>
</where>
LIMIT 50
</select>
<select id="selectCompanyByJobId" resultType="com.ruoyi.common.core.domain.entity.Company">
select a.* from COMPANY a inner join job b on a.company_id=b.company_id and b.job_id=#{jobId} limit 1
</select>
<update id="updateStatus" parameterType="Company">
update COMPANY set company_status=#{companyStatus},update_time=#{updateTime},update_by=#{updateBy} where company_id=#{companyId} and del_flag='0'
</update>
<update id="updateLcToLocalStatus" parameterType="Company">
UPDATE company cn
SET cn.status = #{status},cn.update_time = #{updateTime},cn.update_by = #{updateBy}
WHERE cn.code IN ( SELECT su.id_card FROM sys_user su WHERE su.user_id = #{userId})
AND cn.del_flag = '0'
</update>
<select id="selectAdminCompanyList" parameterType="CompanySearch" resultMap="CompanyResult">
select t.company_id, t.name, t.location, t.industry, t.scale, t.del_flag, t.create_by, t.create_time, t.update_by, t.update_time, t.remark,t.code,t.description,
t.nature,t.company_nature,t.total_recruitment,t.registered_address,t.contact_person,t.contact_person_phone,t.is_abnormal,t.not_pass_reason,t.status,case when t.status='2'
then t.update_time else null end reject_time,t.is_imp_company,t.imp_company_type,t.enterprise_type,t.legal_person,t.legal_id_card,t.legal_phone,t.is_hrs,
(select count(1)
from shz.fair_company fc
join shz.cms_outdoor_fair f on f.id = fc.job_fair_id and f.del_flag = '0'
left join shz.cms_outdoor_fair_company_attendance a
on a.fair_id = fc.job_fair_id and a.company_id = fc.company_id and a.del_flag = '0'
where fc.company_id = t.company_id
and fc.del_flag = '0'
and fc.review_status = '1'
and f.end_time &lt; CURRENT_TIMESTAMP
and coalesce(a.attendance_status, '0') &lt;&gt; '1') as missed_outdoor_fair_count,
su.lc_userid,su.user_id from company t
left join sys_user su on t.code=su.id_card and su.del_flag='0'
<where> t.del_flag = '0' and su.lc_userid is not null
<if test="name != null and name != ''"> and t.name like concat('%', cast(#{name, jdbcType=VARCHAR} as varchar), '%')</if>
<if test="scale != null and scale != ''"> and t.scale = #{scale}</if>
<if test="nature != null and nature != ''"> and t.nature = #{nature}</if>
<if test="companyNature != null and companyNature != ''"> and t.company_nature = #{companyNature}</if>
<if test="code != null and code != ''"> and t.code = #{code}</if>
<if test="status != null and status != ''"> and t.status = #{status}</if>
<if test="companyId != null and companyId != ''"> and t.company_id = #{companyId}</if>
<if test="isHrs != null and isHrs != ''"> and t.is_hrs = #{isHrs}</if>
<if test="legalPerson != null and legalPerson != ''"> and t.legal_person like concat('%', cast(#{legalPerson, jdbcType=VARCHAR} as varchar), '%')</if>
<if test="contactPerson != null and contactPerson != ''">
AND EXISTS (
SELECT 1 FROM company_contact cc
WHERE cc.company_id = t.company_id
AND cc.del_flag = '0'
AND cc.contact_person LIKE concat('%', cast(#{contactPerson, jdbcType=VARCHAR} as varchar), '%')
)
</if>
<if test="contactPersonPhone != null and contactPersonPhone != ''">
AND EXISTS (
SELECT 1 FROM company_contact cc
WHERE cc.company_id = t.company_id
AND cc.del_flag = '0'
AND cc.contact_person_phone LIKE concat('%', cast(#{contactPersonPhone, jdbcType=VARCHAR} as varchar), '%')
)
</if>
<if test="startDate != null and startDate != ''">
and t.create_time >= #{startDate}
</if>
<if test="endDate != null and endDate != ''">
and t.create_time &lt;= #{endDate}
</if>
<if test="missedOutdoorFairOnly == true">
and exists (
select 1
from shz.fair_company fc
join shz.cms_outdoor_fair f on f.id = fc.job_fair_id and f.del_flag = '0'
left join shz.cms_outdoor_fair_company_attendance a
on a.fair_id = fc.job_fair_id and a.company_id = fc.company_id and a.del_flag = '0'
where fc.company_id = t.company_id
and fc.del_flag = '0'
and fc.review_status = '1'
and f.end_time &lt; CURRENT_TIMESTAMP
and coalesce(a.attendance_status, '0') &lt;&gt; '1'
)
</if>
</where>
</select>
<select id="selectMissedOutdoorFairList"
parameterType="long"
resultType="com.ruoyi.cms.domain.vo.CompanyMissedOutdoorFairVO">
SELECT f.id AS fair_id,
f.title,
f.host_unit,
f.address,
f.hold_time,
f.end_time,
fc.create_time AS registration_time
FROM shz.fair_company fc
JOIN shz.cms_outdoor_fair f
ON f.id = fc.job_fair_id
AND f.del_flag = '0'
LEFT JOIN shz.cms_outdoor_fair_company_attendance a
ON a.fair_id = fc.job_fair_id
AND a.company_id = fc.company_id
AND a.del_flag = '0'
WHERE fc.company_id = #{companyId}
AND fc.del_flag = '0'
AND fc.review_status = '1'
AND f.end_time &lt; CURRENT_TIMESTAMP
AND COALESCE(a.attendance_status, '0') &lt;&gt; '1'
ORDER BY f.end_time DESC, f.id DESC
</select>
</mapper>