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.

210 lines
8.3 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">
<resultMap type="BPlanEnterprise" id="BPlanEnterpriseResult">
<result property="id" column="id"/>
<result property="enterpriseId" column="enterprise_id"/>
<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"/>
<result property="district" column="district"/>
<result property="plannedYear" column="planned_year"/>
<result property="planName" column="plan_name"/>
<result property="planContent" column="plan_content"/>
<result property="isPoint" column="is_point"/>
</resultMap>
<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,
plan_name,
plan_content,
is_point
from b_plan_enterprise
</sql>
<select id="selectBPlanEnterpriseList" parameterType="BPlanEnterprise" resultMap="BPlanEnterpriseResult">
<include refid="selectBPlanEnterpriseVo"/>
<where>
<if test="enterpriseId != null and enterpriseId != ''">and enterprise_id = #{enterpriseId}</if>
<if test="createId != null ">and create_id = #{createId}</if>
<if test="updateId != null ">and update_id = #{updateId}</if>
<if test="userId != null ">and user_id = #{userId}</if>
<if test="deptId != null ">and dept_id = #{deptId}</if>
<if test="district != null and district != ''">and district = #{district}</if>
<if test="plannedYear != null and plannedYear != ''">and planned_year = #{plannedYear}</if>
<if test="planName != null and planName != ''">and plan_name like concat('%', #{planName}, '%')</if>
<if test="planContent != null and planContent != ''">and plan_content = #{planContent}</if>
<if test="isPoint != null ">and is_point = #{isPoint}</if>
</where>
</select>
<delete id="deleteByPlanId">
delete
from b_plan_enterprise
where plan_id =
#{planId}
</delete>
<select id="getByPlanId" resultType="com.ruoyi.programManagement.entity.SzEntBasicInfo">
SELECT s.*,
CASE
WHEN c.ent_code IS NOT NULL THEN
1
ELSE 0
END AS is_point
FROM (SELECT b.*, a.plan_id
FROM b_plan_enterprise a
LEFT JOIN sz_ent_basic_info_new b ON a.enterprise_id = b.USC_CODE) s
LEFT JOIN b_key_enterprise c ON s.USC_CODE = c.ent_code
WHERE s.plan_id = #{planId}
GROUP BY s.ENTPR_ID
</select>
<select id="getZhifa" resultType="com.ruoyi.programManagement.entity.response.BPlanEnterpriseZhifaResponse">
SELECT
s.*
FROM
(
SELECT
a.*,
a.planned_year AS plannedYear,
b.id AS longId,
b.EXAMINE_START_TIME,
b.EXAMINE_END_TIME,
b.ENTPR_NAME as entprName,
CASE
WHEN b.USC_CODE IS NOT NULL
AND SUBSTRING( a.planned_year, 1, 7 ) = SUBSTRING( b.EXAMINE_START_TIME, 1, 7 )
THEN 1
ELSE 2
END AS checkStatus
FROM
b_plan_enterprise a
LEFT JOIN sz_enfor_examine b ON a.enterprise_id = b.USC_CODE
WHERE
b.USC_CODE IS NOT NULL
) s
<where>
<if test="req.plannedYear !=null and req.plannedYear !=''">
and s.plannedYear =#{req.plannedYear}
</if>
<if test="req.district !=null and req.district !=''">
and s.district =#{req.district}
</if>
<if test="req.checkStatus !=null and req.checkStatus !=''">
and s.checkStatus =#{req.checkStatus}
</if>
</where>
</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.institution_name AS institutionName,
c.ENTPR_NAME as entprName
FROM
b_plan_enterprise a
LEFT JOIN b_administrative b ON a.district = b.subdistrict
LEFT JOIN sz_ent_basic_info_new c ON a.enterprise_id = c.USC_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>
</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.planned_year,
a.plan_name,
a.plan_content,
a.is_point,
b.ENTPR_NAME as entprName
from b_plan_enterprise a left join sz_ent_basic_info_new b on a.enterprise_id=b.usc_code
where a.id=#{id}
</select>
</mapper>