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.

273 lines
12 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.ruoyi.programManagement.mapper.BEnterpriseNewMapper">
<resultMap type="BEnterpriseNew" id="BEnterpriseNewResult">
<result property="id" column="id"/>
<result property="enterpriseId" column="enterprise_id"/>
<result property="enterpriseName" column="enterprise_name"/>
<result property="district" column="district"/>
<result property="supervisionLarge" column="SUPERVISION_LARGE"/>
<result property="riskLevel" column="RISK_LEVEL"/>
<result property="standLevel" column="STAND_LEVEL"/>
<result property="examineEndTime" column="EXAMINE_END_TIME"/>
<result property="createId" column="create_id"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateId" column="update_id"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="remark" column="remark"/>
<result property="userId" column="user_id"/>
<result property="deptId" column="dept_id"/>
</resultMap>
<sql id="selectBEnterpriseNewVo">
select id,
enterprise_id,
enterprise_name,
district,
SUPERVISION_LARGE,
RISK_LEVEL,
STAND_LEVEL,
EXAMINE_END_TIME,
create_id,
create_by,
create_time,
update_id,
update_by,
update_time,
remark,
user_id,
dept_id
from b_enterprise_new
</sql>
<select id="selectBEnterpriseNewList" parameterType="BEnterpriseNew" resultType="BEnterpriseNewReponse">
SELECT s.*
FROM (
SELECT
a.id,
a.enterprise_id,
a.enterprise_name,
a.district,
a.SUPERVISION_LARGE,
a.RISK_LEVEL,
a.STAND_LEVEL,
a.EXAMINE_END_TIME,
a.create_id,
a.create_by,
a.create_time,
a.update_id,
a.update_by,
a.update_time,
a.remark,
a.user_id,
a.dept_id,
CASE WHEN b.ent_code IS NOT NULL THEN 1 ELSE 2 END AS isPoint
FROM b_enterprise_new a
LEFT JOIN b_key_enterprise b ON a.enterprise_id = b.ent_code
) s
<where>
<if test="enterpriseId != null and enterpriseId != ''">and s.enterprise_id = #{enterpriseId}</if>
<if test="enterpriseName != null and enterpriseName != ''">and s.enterprise_name like concat('%',
#{enterpriseName}, '%')
</if>
<if test="district != null and district.length==3">
and s.district like concat('%',#{district}, '%')
</if>
<if test="district != null and district.length==6">
and s.district like concat('%',#{district}, '%')
</if>
<if test="district != null and district != '' and district.length!=3 and district.length!=6">
and s.district in
<foreach item="item" index="index" collection="district.split(',')" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="supervisionLarge != null and supervisionLarge != ''">and s.SUPERVISION_LARGE =
#{supervisionLarge}
</if>
<if test="riskLevel != null and riskLevel != ''">
and s.RISK_LEVEL in
<foreach item="item" index="index" collection="riskLevel.split(',')" open="(" separator="," close=")">
#{riskLevel}
</foreach>
</if>
<if test="standLevel != null and standLevel != ''">and s.STAND_LEVEL = #{standLevel}</if>
<if test="examineEndTime != null ">and s.EXAMINE_END_TIME = #{examineEndTime}</if>
<if test="createId != null ">and s.create_id = #{createId}</if>
<if test="updateId != null ">and s.update_id = #{updateId}</if>
<if test="userId != null ">and s.user_id = #{userId}</if>
<if test="deptId != null ">and s.dept_id = #{deptId}</if>
<if test="isPoint != null ">and s.isPoint = #{isPoint}</if>
</where>
</select>
<select id="selectBEnterpriseNewById" parameterType="Long" resultMap="BEnterpriseNewResult">
<include refid="selectBEnterpriseNewVo"/>
where id = #{id}
</select>
<insert id="insertBEnterpriseNew" parameterType="BEnterpriseNew" useGeneratedKeys="true" keyProperty="id">
insert into b_enterprise_new
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="enterpriseId != null">enterprise_id,</if>
<if test="enterpriseName != null">enterprise_name,</if>
<if test="district != null">district,</if>
<if test="supervisionLarge != null">SUPERVISION_LARGE,</if>
<if test="riskLevel != null">RISK_LEVEL,</if>
<if test="standLevel != null">STAND_LEVEL,</if>
<if test="examineEndTime != null">EXAMINE_END_TIME,</if>
<if test="createId != null">create_id,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateId != null">update_id,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
<if test="userId != null">user_id,</if>
<if test="deptId != null">dept_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="enterpriseId != null">#{enterpriseId},</if>
<if test="enterpriseName != null">#{enterpriseName},</if>
<if test="district != null">#{district},</if>
<if test="supervisionLarge != null">#{supervisionLarge},</if>
<if test="riskLevel != null">#{riskLevel},</if>
<if test="standLevel != null">#{standLevel},</if>
<if test="examineEndTime != null">#{examineEndTime},</if>
<if test="createId != null">#{createId},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateId != null">#{updateId},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
<if test="userId != null">#{userId},</if>
<if test="deptId != null">#{deptId},</if>
</trim>
</insert>
<update id="updateBEnterpriseNew" parameterType="BEnterpriseNew">
update b_enterprise_new
<trim prefix="SET" suffixOverrides=",">
<if test="enterpriseId != null">enterprise_id = #{enterpriseId},</if>
<if test="enterpriseName != null">enterprise_name = #{enterpriseName},</if>
<if test="district != null">district = #{district},</if>
<if test="supervisionLarge != null">SUPERVISION_LARGE = #{supervisionLarge},</if>
<if test="riskLevel != null">RISK_LEVEL = #{riskLevel},</if>
<if test="standLevel != null">STAND_LEVEL = #{standLevel},</if>
<if test="examineEndTime != null">EXAMINE_END_TIME = #{examineEndTime},</if>
<if test="createId != null">create_id = #{createId},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateId != null">update_id = #{updateId},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="userId != null">user_id = #{userId},</if>
<if test="deptId != null">dept_id = #{deptId},</if>
</trim>
where enterprise_id = #{enterpriseId}
</update>
<delete id="deleteBEnterpriseNewById" parameterType="Long">
delete
from b_enterprise_new
where id = #{id}
</delete>
<delete id="deleteBEnterpriseNewByIds" parameterType="String">
delete from b_enterprise_new where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<delete id="deletAll">
truncate table b_enterprise_new
</delete>
<select id="seletAll" resultType="com.ruoyi.programManagement.entity.BEnterpriseNew">
SELECT a.enterprise_id,
a.enterprise_name,
a.district,
a.SUPERVISION_LARGE,
a.RISK_LEVEL,
COALESCE(b.standardized_grade, '/') AS STAND_LEVEL,
COALESCE(e.MAX_EXAMINE_END_TIME, null) AS EXAMINE_END_TIME
FROM b_enterprise_new a
LEFT JOIN b_standardization b ON a.enterprise_name = b.enterprise_name COLLATE utf8mb4_unicode_ci
LEFT JOIN (
SELECT USC_CODE, MAX(EXAMINE_END_TIME) AS MAX_EXAMINE_END_TIME
FROM sz_enfor_examine
GROUP BY USC_CODE
) e ON a.enterprise_id = e.USC_CODE COLLATE utf8mb4_unicode_ci;
</select>
<select id="getList" resultType="com.ruoyi.programManagement.entity.response.BEnterpriseNewReponse">
select s.* from( SELECT
a.id,
a.enterprise_id,
a.enterprise_name,
a.district,
a.SUPERVISION_LARGE,
a.RISK_LEVEL,
a.STAND_LEVEL,
a.EXAMINE_END_TIME,
a.create_id,
a.create_by,
a.create_time,
a.update_id,
a.update_by,
a.update_time,
a.remark,
a.user_id,
a.dept_id,
CASE WHEN b.ent_code IS NOT NULL THEN 1 ELSE 2 END AS isPoint
FROM b_enterprise_new a
LEFT JOIN b_key_enterprise b ON a.enterprise_id = b.ent_code
LEFT JOIN b_plan_enterprise d ON a.enterprise_id = d.enterprise_id
WHERE d.enterprise_id IS NULL)s
<where>
<if test="enterpriseId != null and enterpriseId != ''">and s.enterprise_id = #{enterpriseId}</if>
<if test="enterpriseName != null and enterpriseName != ''">and s.enterprise_name like concat('%',
#{enterpriseName}, '%')
</if>
<if test="district != null and district.length==3">
and s.district like concat('%',#{district}, '%')
</if>
<if test="district != null and district.length==6">
and s.district like concat('%',#{district}, '%')
</if>
<if test="district != null and district != '' and district.length!=3 and district.length!=6">
and s.district in
<foreach item="item" index="index" collection="district.split(',')" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="supervisionLarge != null and supervisionLarge != ''">and s.SUPERVISION_LARGE =
#{supervisionLarge}
</if>
<if test="riskLevel != null and riskLevel != ''">
and s.RISK_LEVEL in
<foreach item="item" index="index" collection="riskLevel.split(',')" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="standLevel != null and standLevel != ''">and s.STAND_LEVEL = #{standLevel}</if>
<if test="examineEndTime != null ">and s.EXAMINE_END_TIME = #{examineEndTime}</if>
<if test="createId != null ">and s.create_id = #{createId}</if>
<if test="updateId != null ">and s.update_id = #{updateId}</if>
<if test="userId != null ">and s.user_id = #{userId}</if>
<if test="deptId != null ">and s.dept_id = #{deptId}</if>
<if test="isPoint != null ">and s.isPoint = #{isPoint}</if>
</where>
</select>
</mapper>