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.
450 lines
18 KiB
450 lines
18 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.BPlanEnterpriseMapper">
|
|
|
|
|
|
<sql id="selectBPlanEnterpriseVo">
|
|
select id,
|
|
enterprise_id,
|
|
create_id,
|
|
create_by,
|
|
create_time,
|
|
update_id,
|
|
update_by,
|
|
update_time,
|
|
remark,
|
|
user_id,
|
|
dept_id,
|
|
district,
|
|
planned_year,
|
|
is_point,
|
|
enterprise_name,
|
|
law_sort,
|
|
law_areas,
|
|
law_level,
|
|
law_hierarchy,
|
|
planned_month,
|
|
status,
|
|
check_status,
|
|
check_id,
|
|
check_ageing,
|
|
uuto,
|
|
check_time
|
|
from b_plan_enterprise
|
|
</sql>
|
|
|
|
|
|
|
|
<select id="selectBPlanEnterpriseList" parameterType="BPlanEnterprise" resultType="BPlanEnterpriseResponse">
|
|
SELECT
|
|
a.id,
|
|
a.enterprise_id,
|
|
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,
|
|
a.district,
|
|
a.planned_year,
|
|
a.is_point,
|
|
a.enterprise_name,
|
|
a.law_sort,
|
|
a.law_areas,
|
|
a.law_level,
|
|
a.law_hierarchy,
|
|
a.uuto,
|
|
a.check_time,
|
|
a.planned_month as plannedMonth,
|
|
a.status,
|
|
a.check_status,
|
|
a.check_id,
|
|
a.check_ageing,
|
|
CONCAT(d.district,'-', d.county) AS districtcounty
|
|
FROM b_plan_enterprise a
|
|
left join b_administrative_division d on a.district=d.county_code
|
|
<where>
|
|
<if test="enterpriseId != null and enterpriseId != ''">and a.enterprise_id = #{enterpriseId}</if>
|
|
<if test="createId != null ">and a.create_id = #{createId}</if>
|
|
<if test="updateId != null ">and a.update_id = #{updateId}</if>
|
|
<if test="userId != null ">and a.user_id = #{userId}</if>
|
|
<if test="deptId != null ">and a.dept_id = #{deptId}</if>
|
|
<if test="district != null and district.length==3">
|
|
and a.district like concat('%',#{district}, '%')
|
|
</if>
|
|
<if test="district != null and district.length==6">
|
|
and a.district like concat('%',#{district}, '%')
|
|
</if>
|
|
<if test="district != null and district != '' and district.length!=3 and district.length!=6">
|
|
and a.district in
|
|
<foreach item="item" index="index" collection="district.split(',')" open="(" separator="," close=")">
|
|
#{item}
|
|
</foreach>
|
|
</if>
|
|
|
|
<if test="plannedYear != null and plannedYear != ''">and a.planned_year = #{plannedYear}</if>
|
|
<if test="lawHierarchy != null ">and a.law_hierarchy = #{lawHierarchy}</if>
|
|
<if test="status != null ">and a.status = #{status}</if>
|
|
<if test="enterpriseName != null and enterpriseName != ''">and a.enterprise_name like
|
|
concat('%',#{enterpriseName}, '%')
|
|
</if>
|
|
<if test="plannedMonth != null and plannedMonth.length > 0">
|
|
AND a.planned_month IN
|
|
<foreach item="item" collection="plannedMonth" open="(" separator="," close=")">
|
|
#{item}
|
|
</foreach>
|
|
</if>
|
|
</where>
|
|
</select>
|
|
<delete id="deleteByPlanId">
|
|
delete
|
|
from b_plan_enterprise
|
|
where plan_id =
|
|
#{planId}
|
|
</delete>
|
|
|
|
<select id="getZhifa" resultType="com.ruoyi.programManagement.entity.response.BPlanEnterpriseZhifaResponse">
|
|
|
|
SELECT
|
|
a.id,
|
|
a.enterprise_id,
|
|
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,
|
|
a.district,
|
|
a.planned_year,
|
|
a.is_point,
|
|
a.enterprise_name,
|
|
a.law_sort,
|
|
a.law_areas,
|
|
a.law_level,
|
|
a.law_hierarchy,
|
|
a.planned_month,
|
|
a.status,
|
|
a.uuto,
|
|
a.check_time,
|
|
a.check_status,
|
|
a.check_id,
|
|
a.check_ageing,
|
|
c.RISK_LEVEL as riskLevel,
|
|
c.STAND_LEVEL as standLevel,
|
|
c.EXAMINE_END_TIME as examineEndTime,
|
|
CASE WHEN b.ent_code IS NOT NULL THEN 1 ELSE 2 END AS isPoint,
|
|
CONCAT(d.district,'-', d.county) AS districtcounty
|
|
FROM b_plan_enterprise a
|
|
LEFT JOIN b_key_enterprise b ON a.enterprise_id = b.ent_code
|
|
LEFT JOIN b_enterprise_new c ON a.enterprise_id = c.enterprise_id
|
|
left join b_administrative_division d on a.district=d.county_code
|
|
<where>
|
|
<if test="req.plannedYear !=null and req.plannedYear !=''">
|
|
and a.planned_year =#{req.plannedYear}
|
|
</if>
|
|
<if test="req.status !=null and req.status !=''">
|
|
and a.status =#{req.status}
|
|
</if>
|
|
<if test="req.enterpriseName !=null and req.enterpriseName !=''">
|
|
and a.enterprise_name like concat('%', #{req.enterpriseName}, '%')
|
|
</if>
|
|
<if test="req.checkStatus !=null and req.checkStatus !=''">
|
|
and a.check_status =#{req.checkStatus}
|
|
</if>
|
|
<if test="req.district !=null and req.district !=''">
|
|
and a.district like concat('%', #{req.district}, '%')
|
|
</if>
|
|
<if test="req.plannedMonth != null and req.plannedMonth.length > 0">
|
|
AND a.planned_month IN
|
|
<foreach item="item" collection="req.plannedMonth" open="(" separator="," close=")">
|
|
#{item}
|
|
</foreach>
|
|
</if>
|
|
</where>
|
|
order by law_sort,planned_month+0
|
|
</select>
|
|
<select id="page" resultType="com.ruoyi.programManagement.entity.BPlanEnterprise">
|
|
select * from b_plan_enterprise
|
|
<where>
|
|
<if test="req.plannedYear !=null and req.plannedYear !=''">
|
|
and plannedYear =#{req.plannedYear}
|
|
</if>
|
|
<if test="req.district !=null and req.district !=''">
|
|
and district =#{req.district}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
<select id="getzhifacount" resultType="com.ruoyi.programManagement.entity.response.zhifaCountResponse">
|
|
SELECT bpm.dept_id as deptId,
|
|
c.dept_name as deptName ,
|
|
COUNT(CASE WHEN bpe.is_point = 1 THEN 1 END) as keyPlan,
|
|
COUNT(CASE WHEN bpe.is_point = 2 THEN 1 END) as nonKeyPlan,
|
|
COUNT(CASE WHEN bpe.is_point = 1 AND exm.USC_CODE IS NOT NULL THEN 1 END) as keyCompleted ,
|
|
COUNT(CASE WHEN bpe.is_point = 2 AND exm.USC_CODE IS NULL THEN 1 END) as nonKeyCompleted,
|
|
COUNT(CASE WHEN bpe.is_point = 1 AND exm.USC_CODE IS NOT NULL THEN 1 END) * 100 /
|
|
COUNT(CASE WHEN bpe.is_point = 1 THEN 1 END) as percentageCompleted,
|
|
COUNT(CASE WHEN bpe.is_point = 2 AND exm.USC_CODE IS NULL THEN 1 END) * 100 /
|
|
COUNT(CASE WHEN bpe.is_point = 2 THEN 1 END) as percentageNonCompleted,
|
|
COUNT(*) as totalPlanCount
|
|
FROM b_plan_manage bpm
|
|
JOIN
|
|
b_plan_enterprise bpe ON bpm.id = bpe.plan_id
|
|
LEFT JOIN
|
|
sz_enfor_examine exm ON bpe.enterprise_id = exm.USC_CODE
|
|
LEFT JOIN sys_dept c on bpm.dept_id = c.dept_id
|
|
<where>
|
|
<if test="req.plannedYear !=null and req.plannedYear !=''">
|
|
and bpm.planned_year =#{req.plannedYear}
|
|
</if>
|
|
<if test="req.deptName !=null and req.deptName !=''">
|
|
and c.dept_name =#{req.deptName}
|
|
</if>
|
|
</where>
|
|
GROUP BY bpm.dept_id
|
|
</select>
|
|
<select id="getplan" resultType="com.ruoyi.programManagement.entity.response.zhifaPlanResponse">
|
|
SELECT COUNT(*) AS count, b.dept_name AS deptName
|
|
FROM b_plan_manage a
|
|
LEFT JOIN sys_dept b
|
|
ON a.dept_id = b.dept_id
|
|
WHERE b.ancestors REGEXP '^([^,]*,){0,1}[^,]*$'
|
|
GROUP BY a.dept_id
|
|
</select>
|
|
<select id="getPlanMx" resultType="com.ruoyi.programManagement.entity.response.PlanMxResponse">
|
|
SELECT
|
|
a.*,
|
|
b.DISTRICT_NAME AS institutionName,
|
|
a.ENTERPRISE_NAME as enterpriseName
|
|
FROM
|
|
b_plan_enterprise a
|
|
LEFT JOIN szs_administrative_division b ON a.district = b.DISTRICT_CODE
|
|
<where>
|
|
<if test="req.district !=null and req.district!='' ">
|
|
AND a.district like concat('%', #{req.district}, '%')
|
|
</if>
|
|
<if test="req.plannedYear !=null and req.plannedYear!='' ">
|
|
and a.planned_year =#{req.plannedYear}
|
|
</if>
|
|
<if test="req.enterpriseName !=null and req.enterpriseName!='' ">
|
|
and a.ENTERPRISE_NAME like concat('%', #{req.enterpriseName}, '%')
|
|
</if>
|
|
|
|
</where>
|
|
group by a.id order by a.id desc
|
|
</select>
|
|
<select id="selectById" resultType="com.ruoyi.programManagement.entity.BPlanEnterprise">
|
|
select a.id,
|
|
a.enterprise_id,
|
|
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,
|
|
a.district,
|
|
a.uuto,
|
|
a.check_time,
|
|
a.planned_year,
|
|
a.is_point,
|
|
a.enterprise_name as entprName
|
|
from b_plan_enterprise a
|
|
where a.id = #{id}
|
|
</select>
|
|
<select id="getShouyeList"
|
|
resultType="com.ruoyi.programManagement.entity.response.BPlanEnterPriseTreeResponse">
|
|
|
|
SELECT
|
|
IFNULL(law_areas, '合计') AS lawAreas,
|
|
MAX(law_sort) AS sort,
|
|
COUNT(law_areas) AS count,
|
|
SUM(CASE WHEN check_status = 1 THEN 1 ELSE 0 END) AS completed,
|
|
ROUND(100 * SUM(CASE WHEN check_status = 1 THEN 1 ELSE 0 END) / COUNT(law_areas)) AS completion_rate
|
|
FROM b_plan_enterprise
|
|
<where>
|
|
<if test="req.plannedYear !=null and req.plannedYear!='' ">
|
|
and planned_year =#{req.plannedYear}
|
|
</if>
|
|
<if test="req.plannedMonth != null and req.plannedMonth.length > 0">
|
|
AND planned_month IN
|
|
<foreach item="item" collection="req.plannedMonth" open="(" separator="," close=")">
|
|
#{item}
|
|
</foreach>
|
|
</if>
|
|
and status=1
|
|
</where>
|
|
GROUP BY law_areas WITH ROLLUP
|
|
ORDER BY
|
|
CASE WHEN GROUPING(law_areas) = 1 THEN 1 ELSE 0 END,
|
|
sort
|
|
|
|
|
|
</select>
|
|
<select id="getShouYeMxList"
|
|
resultType="com.ruoyi.programManagement.entity.response.BPlanEnterPriseTreeResponse">
|
|
SELECT
|
|
IFNULL(law_hierarchy, '合计') AS lawAreas,
|
|
MAX(law_sort) AS sort,
|
|
COUNT(law_areas) AS count,
|
|
SUM(CASE WHEN check_status = 1 THEN 1 ELSE 0 END) AS completed,
|
|
ROUND(100 * SUM(CASE WHEN check_status = 1 THEN 1 ELSE 0 END) / COUNT(law_areas)) AS completion_rate
|
|
FROM b_plan_enterprise
|
|
<where>
|
|
<if test="req.plannedYear !=null and req.plannedYear!='' ">
|
|
and planned_year =#{req.plannedYear}
|
|
</if>
|
|
<if test="req.plannedMonth != null and req.plannedMonth.length > 0">
|
|
AND planned_month IN
|
|
<foreach item="item" collection="req.plannedMonth" open="(" separator="," close=")">
|
|
#{item}
|
|
</foreach>
|
|
</if>
|
|
<if test="req.lawAreas !=null and req.lawAreas!='' ">
|
|
and law_areas =#{req.lawAreas}
|
|
</if>
|
|
and status=1
|
|
</where>
|
|
GROUP BY law_hierarchy WITH ROLLUP
|
|
ORDER BY
|
|
CASE WHEN GROUPING(law_hierarchy) = 1 THEN 1 ELSE 0 END,
|
|
sort
|
|
|
|
</select>
|
|
<select id="selectUpdateAll" resultType="com.ruoyi.programManagement.entity.BPlanEnterprise">
|
|
SELECT a.id, a.enterprise_id, a.district, a.planned_year, a.is_point, a.enterprise_name, a.law_sort, a.law_areas, a.law_level, a.law_hierarchy, a.planned_month, a.status,e.MAX_EXAMINE_END_TIME as check_time,
|
|
CASE
|
|
WHEN e.MAX_EXAMINE_END_TIME IS NULL THEN 0
|
|
WHEN YEAR(e.MAX_EXAMINE_END_TIME) = a.planned_year AND MONTH(e.MAX_EXAMINE_END_TIME) = a.planned_month THEN 1
|
|
WHEN YEAR(e.MAX_EXAMINE_END_TIME) < a.planned_year OR (YEAR(e.MAX_EXAMINE_END_TIME) = a.planned_year AND MONTH(e.MAX_EXAMINE_END_TIME) < a.planned_month) THEN 2
|
|
ELSE 3
|
|
END AS check_ageing,
|
|
e.ID AS check_id,
|
|
CASE
|
|
WHEN e.ID IS NOT NULL THEN 1
|
|
ELSE 0
|
|
END AS check_status
|
|
FROM b_plan_enterprise a
|
|
LEFT JOIN (
|
|
SELECT USC_CODE, MAX(EXAMINE_END_TIME) AS MAX_EXAMINE_END_TIME, ID
|
|
FROM sz_enfor_examine
|
|
WHERE YEAR(EXAMINE_END_TIME) = YEAR(CURDATE())
|
|
GROUP BY USC_CODE, ID
|
|
) e ON a.enterprise_id = e.USC_CODE
|
|
</select>
|
|
|
|
<update id="updateIdList" parameterType="java.util.List">
|
|
UPDATE b_plan_enterprise
|
|
SET status = 1
|
|
WHERE id in
|
|
<foreach item="item" collection="list" open="(" separator="," close=")">
|
|
#{item}
|
|
</foreach>
|
|
</update>
|
|
|
|
<update id="updatePlan" parameterType="BPlanEnterpriseRequest">
|
|
update b_plan_enterprise
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="enterpriseId != null">enterprise_id=#{enterpriseId},</if>
|
|
<if test="district != null">district=#{district},</if>
|
|
<if test="plannedYear != null">planned_year=#{plannedYear},</if>
|
|
<if test="isPoint != null">is_point=#{isPoint},</if>
|
|
<if test="enterpriseName != null">enterprise_name=#{enterpriseName},</if>
|
|
<if test="lawSort != null">law_sort=#{lawSort},</if>
|
|
<if test="lawAreas != null">law_areas=#{lawAreas},</if>
|
|
<if test="lawLevel != null">law_level=#{lawLevel},</if>
|
|
<if test="lawHierarchy != null">law_hierarchy=#{lawHierarchy},</if>
|
|
<if test="plannedMonth != null">planned_month=#{plannedMonth},</if>
|
|
<if test="status != null">status=#{status},</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>
|
|
<if test="uuto != null">uuto =#{uuto},</if>
|
|
</trim>
|
|
where id = #{id}
|
|
</update>
|
|
<update id="updateEndTime">
|
|
UPDATE b_enterprise_new a
|
|
INNER JOIN (
|
|
SELECT
|
|
USC_CODE,
|
|
MAX_EXAMINE_END_TIME
|
|
FROM
|
|
( SELECT ROW_NUMBER ( ) over ( PARTITION BY USC_CODE ORDER BY EXAMINE_END_TIME DESC ) rowId, USC_CODE, EXAMINE_END_TIME AS MAX_EXAMINE_END_TIME FROM sz_enfor_examine ) S
|
|
WHERE
|
|
rowId = 1
|
|
) c
|
|
ON a.enterprise_id = c.USC_CODE
|
|
SET a.EXAMINE_END_TIME = c.MAX_EXAMINE_END_TIME
|
|
</update>
|
|
|
|
|
|
<insert id="insertPlan" parameterType="BPlanEnterpriseRequest" useGeneratedKeys="true" keyProperty="id">
|
|
insert into b_plan_enterprise
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="enterpriseId != null">enterprise_id,</if>
|
|
<if test="district != null">district,</if>
|
|
<if test="plannedYear != null">planned_year,</if>
|
|
<if test="isPoint != null">is_point,</if>
|
|
<if test="enterpriseName != null">enterprise_name,</if>
|
|
<if test="lawSort != null">law_sort,</if>
|
|
<if test="lawAreas != null">law_areas,</if>
|
|
<if test="lawLevel != null">law_level,</if>
|
|
<if test="lawHierarchy != null">law_hierarchy,</if>
|
|
<if test="plannedMonth != null">planned_month,</if>
|
|
<if test="status != null">status,</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>
|
|
<if test="uuto != null">uuto,</if>
|
|
<if test="checkStatus != null">check_status,</if>
|
|
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="enterpriseId != null">#{enterpriseId},</if>
|
|
<if test="district != null">#{district},</if>
|
|
<if test="plannedYear != null">#{plannedYear},</if>
|
|
<if test="isPoint != null">#{isPoint},</if>
|
|
<if test="enterpriseName != null">#{enterpriseName},</if>
|
|
<if test="lawSort != null">#{lawSort},</if>
|
|
<if test="lawAreas != null">#{lawAreas},</if>
|
|
<if test="lawLevel != null">#{lawLevel}, </if>
|
|
<if test="lawHierarchy != null">#{lawHierarchy},</if>
|
|
<if test="plannedMonth != null">#{plannedMonth},</if>
|
|
<if test="status != null">#{status},</if>
|
|
<if test="createId != null">create_id,</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>
|
|
<if test="uuto != null">#{uuto},</if>
|
|
<if test="checkStatus != null">#{checkStatus},</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
</mapper> |