jl-jjsp-service/securityControl-modules/securityControl-proteam/target/classes/mapper/dutyTask/ReportBackupsMapper.xml

525 lines
23 KiB
XML
Raw Permalink Normal View History

2025-09-24 11:10:04 +08:00
<?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.sercurityControl.proteam.dutyTask.mapper.ReportBackupsMapper">
<!--保存地市日报数据-->
<insert id="addData" useGeneratedKeys="true" keyProperty="id">
<if test="id!=null and storeStatus == 0">
UPDATE tb_city_daily_report_backups
SET data_json = #{dataJson},
store_status = #{storeStatus},
org_id = #{orgId},
current_day = #{currentDay}
WHERE id = #{id}
</if>
<if test="id!=null and storeStatus == 1">
UPDATE tb_city_daily_report_backups
SET store_status = #{storeStatus}
WHERE id = #{id}
</if>
<if test="id==null">
INSERT INTO tb_city_daily_report_backups
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="orgId != null and orgId!=''">org_id,</if>
<if test="dataJson != null and dataJson!=''">data_json,</if>
<if test="currentDay != null">current_day,</if>
<if test="storeStatus != null and storeStatus != ''">store_status,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orgId != null and orgId!=''">#{orgId},</if>
<if test="dataJson != null and dataJson!=''">#{dataJson},</if>
<if test="currentDay != null">#{currentDay},</if>
<if test="storeStatus != null and storeStatus != ''">#{storeStatus},</if>
</trim>
</if>
</insert>
<!--申请退回日报数据/审核日报数据-->
<update id="updateDailyStatus">
UPDATE tb_city_daily_report_backups SET store_status = #{storeStatus} WHERE id = #{id}
</update>
<!--查询地市日报数据-->
<select id="getData" resultType="com.sercurityControl.proteam.dutyTask.domain.CityDailyDutyReportVo">
SELECT tcdr.id,
tcdr.data_json AS dataJson,
tcdr.store_status AS storeStatus,
tcdr.org_id AS orgId,
tcdr.current_day AS currentDay,
so.city_name AS orgName
FROM tb_city_daily_report_backups tcdr
LEFT JOIN sys_org so ON so.org_id = tcdr.org_id
WHERE tcdr.org_id = #{orgId}
AND tcdr.current_day = #{currentDay} AND tcdr.del_status = '1'
ORDER BY tcdr.id DESC
LIMIT 1
</select>
<!--班组及人员情况-->
<select id="getNumList" resultType="java.lang.Integer">
SELECT IFNULL(count(1),0) num
FROM jj_ticket
WHERE (ticket_status='05' OR (ticket_status = '06' AND DATE_FORMAT(end_time,'%Y-%m-%d') =#{currentDay})) AND delete_flag=0
<if test="type == 1">
<if test="orgId!=null and orgId!=''">
AND build_unit_code = #{orgId}
</if>
</if>
<if test="type == 2">
<if test="orgIds != null and orgIds.size() > 0">
AND build_unit_code IN
<foreach collection="orgIds" item="orgId" open="(" separator="," close=")">
#{orgId}
</foreach>
</if>
AND build_unit_code !='12Z0'
</if>
UNION ALL
SELECT IFNULL(count(1),0) num
FROM jj_class_meetting jcm
WHERE jcm.current_constr_date=#{currentDay} AND jcm.delete_flag=0
<if test="type == 1">
<if test="orgId!=null and orgId!=''">
AND build_unit_code = #{orgId}
</if>
</if>
<if test="type == 2">
<if test="orgIds != null and orgIds.size() > 0">
AND build_unit_code IN
<foreach collection="orgIds" item="orgId" open="(" separator="," close=")">
#{orgId}
</foreach>
</if>
AND build_unit_code !='12Z0'
</if>
UNION ALL
SELECT IFNULL(count(jcmp.id),0) num
FROM jj_class_meetting jcm
LEFT JOIN jj_class_meeting_people jcmp ON jcm.id=jcmp.tool_box_talk_id AND jcmp.delete_flag = 0
WHERE jcm.current_constr_date=#{currentDay} AND jcm.delete_flag=0
<if test="type == 1">
<if test="orgId!=null and orgId!=''">
AND build_unit_code = #{orgId}
</if>
</if>
<if test="type == 2">
<if test="orgIds != null and orgIds.size() > 0">
AND build_unit_code IN
<foreach collection="orgIds" item="orgId" open="(" separator="," close=")">
#{orgId}
</foreach>
</if>
AND build_unit_code !='12Z0'
</if>
</select>
<!--今日二级风险明细-->
<select id="getTwoRiskList"
resultType="com.sercurityControl.proteam.dutyTask.domain.CityDailyDutyReportDownloadVo$TwoRiskVo">
SELECT jcm.single_project_name AS proName,
jcm.id,
jcmi.work_content AS workContent,
so.city_name AS orgName
FROM jj_class_meetting jcm
LEFT JOIN sys_org so on so.org_id=jcm.build_unit_code
LEFT JOIN jj_class_metting_info jcmi on jcm.id =jcmi.class_id
WHERE jcm.delete_flag=0 AND jcm.current_constr_date = #{currentDay}
<if test="type == 1">
<if test="orgId!=null and orgId!=''">
AND jcm.build_unit_code = #{orgId}
</if>
</if>
<if test="type == 2">
<if test="orgIds != null and orgIds.size() > 0">
AND jcm.build_unit_code IN
<foreach collection="orgIds" item="orgId" open="(" separator="," close=")">
#{orgId}
</foreach>
</if>
AND jcm.build_unit_code !='12Z0'
</if>
AND jcm.re_assessment_risk_level=2
</select>
<!--违章情况-地市自查-->
<select id="getVioList"
resultType="com.sercurityControl.proteam.dutyTask.domain.CityDailyDutyReportDownloadVo$VioVo">
SELECT tnv.level_id AS levelId,
CONCAT(tnv.pro_name,'',tnv.team_name,'') AS proName,
tnv.voi_yj AS voiYj,
tnv.content,
so.city_name AS orgName,
CASE tnv.status WHEN '1' THEN '未处理'
WHEN '5' THEN '已处理'
ELSE '未知' END AS status,
id
FROM t_notice_voi tnv
LEFT JOIN sys_org so ON so.org_id = tnv.org
WHERE tnv.create_time = #{currentDay} AND tnv.sup_type = '2' AND tnv.is_flag = '0' AND tnv.level_id = '2' IN ('一般违章','严重违章')
<if test="type == 1">
<if test="orgId!=null and orgId!=''">
AND tnv.org = #{orgId}
</if>
</if>
<if test="type == 2">
<if test="orgIds != null and orgIds.size() > 0">
AND tnv.org IN
<foreach collection="orgIds" item="orgId" open="(" separator="," close=")">
#{orgId}
</foreach>
</if>
AND tnv.org !='12Z0'
</if>
ORDER BY FIELD(level_id, '严重违章','一般违章')
</select>
<select id="getOnDuty" resultType="java.util.Map">
SELECT
count(if(onduty_hierarchy='10',1,null)) sg,
count(if(onduty_hierarchy='20',1,null)) jl,
count(if(onduty_hierarchy='30',1,null)) yz
FROM jj_on_duty
WHERE delete_flag=0
AND tool_box_talk_id = #{id}
</select>
<!--查询违章照片-->
<select id="getImgList"
resultType="com.sercurityControl.proteam.dutyTask.domain.CityDailyDutyReportDownloadVo$ImgVo">
SELECT id,image_path AS base64Url
FROM t_notice_voi_photo
WHERE noti_id = #{id} AND image_type = '1'
</select>
<!--查询日报上报截止日期-->
<select id="getEndTime" resultType="java.lang.String">
SELECT sd2.name
FROM sys_dist sd
LEFT JOIN sys_dist sd2 ON sd2.p_id = sd.id AND sd2.is_flag = '0'
WHERE sd.code = 'daily_upload_time' AND sd.is_flag = '0'
LIMIT 1
</select>
<!--查询地市日报汇总数据-->
<select id="getSummaryData"
resultType="com.sercurityControl.proteam.dutyTask.domain.CityDailyDutyReportVo">
SELECT tcdr.id,
tcdr.data_json AS dataJson,
tcdr.store_status AS storeStatus,
tcdr.org_id AS orgId,
tcdr.current_day AS currentDay,
so.city_name AS orgName
FROM tb_city_daily_report_backups tcdr
LEFT JOIN sys_org so ON so.org_id = tcdr.org_id
WHERE tcdr.current_day = #{currentDay} AND tcdr.del_status = '1' AND tcdr.store_status IN ('1','2','3')
<if test="orgIds != null and orgIds.size() > 0">
AND tcdr.org_id IN
<foreach collection="orgIds" item="orgId" open="(" separator="," close=")">
#{orgId}
</foreach>
</if>
AND tcdr.org_id !='12Z0'
ORDER BY tcdr.org_id
</select>
<!--地市自查违章数量-->
<select id="getVioNumList" resultType="java.lang.Integer">
SELECT IFNULL(COUNT(1),0) num
FROM t_notice_voi
WHERE create_time = #{currentDay} AND sup_type = '2' AND is_flag = '0' AND level_id IN ('一般违章','严重违章')
<if test="type == 1">
<if test="orgId!=null and orgId!=''">
AND org = #{orgId}
</if>
</if>
<if test="type == 2">
<if test="orgIds != null and orgIds.size() > 0">
AND org IN
<foreach collection="orgIds" item="orgId" open="(" separator="," close=")">
#{orgId}
</foreach>
</if>
AND org !='12Z0'
</if>
UNION ALL
SELECT IFNULL(COUNT(1),0) num
FROM t_notice_voi
WHERE create_time = #{currentDay} AND sup_type = '2' AND is_flag = '0' AND level_id = '严重违章'
<if test="type == 1">
<if test="orgId!=null and orgId!=''">
AND org = #{orgId}
</if>
</if>
<if test="type == 2">
<if test="orgIds != null and orgIds.size() > 0">
AND org IN
<foreach collection="orgIds" item="orgId" open="(" separator="," close=")">
#{orgId}
</foreach>
</if>
AND org !='12Z0'
</if>
UNION ALL
SELECT IFNULL(COUNT(1),0) num
FROM t_notice_voi
WHERE create_time = #{currentDay} AND sup_type = '2' AND is_flag = '0' AND level_id = '一般违章'
<if test="type == 1">
<if test="orgId!=null and orgId!=''">
AND org = #{orgId}
</if>
</if>
<if test="type == 2">
<if test="orgIds != null and orgIds.size() > 0">
AND org IN
<foreach collection="orgIds" item="orgId" open="(" separator="," close=")">
#{orgId}
</foreach>
</if>
AND org !='12Z0'
</if>
</select>
<!--今日三级及以上风险和今日站班会数量-->
<select id="getClassNums" resultType="java.lang.Integer">
SELECT COUNT(*)
FROM jj_class_meetting jcm
WHERE jcm.current_constr_date=#{currentDay} AND jcm.delete_flag=0 AND jcm.re_assessment_risk_level IN (2,3)
<if test="type == 1">
<if test="orgId!=null and orgId!=''">
AND jcm.build_unit_code = #{orgId}
</if>
</if>
<if test="type == 2">
<if test="orgIds != null and orgIds.size() > 0">
AND jcm.build_unit_code IN
<foreach collection="orgIds" item="orgId" open="(" separator="," close=")">
#{orgId}
</foreach>
</if>
AND jcm.build_unit_code !='12Z0'
</if>
UNION ALL
SELECT COUNT(*)
FROM jj_class_meetting jcm
WHERE jcm.current_constr_date=#{currentDay} AND jcm.delete_flag=0
<if test="type == 1">
<if test="orgId!=null and orgId!=''">
AND jcm.build_unit_code = #{orgId}
</if>
</if>
<if test="type == 2">
<if test="orgIds != null and orgIds.size() > 0">
AND jcm.build_unit_code IN
<foreach collection="orgIds" item="orgId" open="(" separator="," close=")">
#{orgId}
</foreach>
</if>
AND jcm.build_unit_code !='12Z0'
</if>
</select>
<!--查询昨日填报的地市数据-->
<select id="getYeDailyData"
resultType="com.sercurityControl.proteam.dutyTask.domain.CityDailyDutyReportVo">
SELECT tcdr.id,
tcdr.data_json AS dataJson,
tcdr.store_status AS storeStatus,
tcdr.org_id AS orgId,
tcdr.current_day AS currentDay,
so.city_name AS orgName
FROM tb_city_daily_report_backups tcdr
LEFT JOIN sys_org so ON so.org_id = tcdr.org_id
WHERE tcdr.current_day = #{yeDay} AND tcdr.del_status = '1'
<if test="type == 1">
<if test="orgId != null and orgId!=''">
AND tcdr.org_id = #{orgId}
</if>
</if>
<if test="type == 2 or type == 3">
<if test="orgIds != null and orgIds.size() > 0">
AND tcdr.org_id IN
<foreach collection="orgIds" item="orgId" open="(" separator="," close=")">
#{orgId}
</foreach>
</if>
AND tcdr.store_status IN ('1','2','3')
AND tcdr.org_id !='12Z0'
</if>
ORDER BY tcdr.org_id
</select>
<!--站班会二级三级风险数量-->
<select id="getClassNumByOrg" resultType="java.util.Map">
SELECT so.org_id AS orgId,
so.city_name AS orgName,
IFNULL(A.twoRiskNum,0) AS twoRiskNum,
IFNULL(A.threeRiskNum,0) AS threeRiskNum,
0 AS twoNum,
0 AS threeNum,
0 AS twoRate,
0 AS threeRate
FROM sys_org so
LEFT JOIN (
SELECT jcm.build_unit_code AS orgId,
ANY_VALUE(COUNT(IF(jcm.re_assessment_risk_level = '2',1,NULL))) AS twoRiskNum,
ANY_VALUE(COUNT(IF(jcm.re_assessment_risk_level = '3',1,NULL))) AS threeRiskNum
FROM jj_class_meetting jcm
WHERE jcm.current_constr_date=#{currentDay} AND jcm.delete_flag=0 AND jcm.re_assessment_risk_level IN (2,3)
GROUP BY jcm.build_unit_code
) A ON A.orgId = so.org_id
<where>
<if test="type == 1">
<if test="orgId!=null and orgId!=''">
AND so.org_id = #{orgId}
</if>
</if>
<if test="type == 2 or type == 3">
<if test="orgIds != null and orgIds.size() > 0">
AND so.org_id IN
<foreach collection="orgIds" item="orgId" open="(" separator="," close=")">
#{orgId}
</foreach>
</if>
AND so.org_id !='12Z0'
</if>
ORDER BY (twoRiskNum + threeRiskNum) DESC
</where>
</select>
<!--查询安全质量检查总体情况-表格数据-->
<select id="getDatas" resultType="com.sercurityControl.proteam.dutyTask.domain.DailyDutyReportVo$DataVo">
SELECT so.org_id AS orgId,
so.city_name AS orgName,
IFNULL(A.num,0) AS num,
IFNULL(B.num2,0) AS num2,
IFNULL(B.num3,0) AS num3
FROM sys_org so
LEFT JOIN (
SELECT COUNT(*) AS num,jcm.build_unit_code AS orgId
FROM jj_class_meetting jcm
WHERE jcm.current_constr_date=#{currentDay} AND jcm.delete_flag=0
GROUP BY jcm.build_unit_code
) A ON A.orgId = so.org_id
LEFT JOIN (
SELECT org AS orgId,
ANY_VALUE(COUNT(IF(level_id = '严重违章',1,NULL))) AS num2,
ANY_VALUE(COUNT(IF(level_id = '一般违章',1,NULL))) AS num3
FROM t_notice_voi
WHERE create_time = #{currentDay} AND sup_type = '2' AND is_flag = '0' AND level_id IN ('严重违章','一般违章')
GROUP BY org
) B ON B.orgId = so.org_id
WHERE so.org_id !='12Z0'
ORDER BY num DESC
</select>
<!--今日视频监控接入情况-->
<select id="getVideoNum" resultType="java.lang.Integer">
SELECT COUNT(*) AS num
FROM jj_class_meetting jcm
WHERE jcm.current_constr_date=#{currentDay} AND jcm.delete_flag=0 AND jcm.re_assessment_risk_level IN (2,3)
UNION ALL
SELECT COUNT(*) AS num
FROM jj_class_meetting jcm
WHERE jcm.current_constr_date=#{currentDay} AND jcm.delete_flag=0 AND jcm.re_assessment_risk_level IN (2,3) AND jcm.camera_id IS NOT NULL
UNION ALL
SELECT COUNT(*) AS num
FROM jj_class_meetting jcm
WHERE jcm.current_constr_date=#{currentDay} AND jcm.delete_flag=0 AND jcm.re_assessment_risk_level IN (4,5)
UNION ALL
SELECT COUNT(*) AS num
FROM jj_class_meetting jcm
LEFT JOIN jj_class_metting_info jcmi ON jcmi.class_id = jcm.id
WHERE jcm.current_constr_date=#{currentDay} AND jcm.delete_flag=0 AND jcm.re_assessment_risk_level = 4 AND (INSTR(jcmi.work_content,'起重机') > 0 OR INSTR(jcmi.work_content,'跨越架') > 0)
UNION ALL
SELECT COUNT(*) AS num
FROM jj_class_meetting jcm
WHERE jcm.current_constr_date=#{currentDay} AND jcm.delete_flag=0 AND jcm.re_assessment_risk_level IN (4,5) AND jcm.camera_id IS NOT NULL
</select>
<!--督查情况-总体情况-->
<select id="getDcNum" resultType="java.lang.Integer">
SELECT COUNT(*) AS num
FROM jj_class_meetting jcm
WHERE jcm.current_constr_date= #{currentDay} AND jcm.delete_flag=0
UNION ALL
SELECT COUNT(*) AS num
FROM jj_class_meetting jcm
WHERE jcm.current_constr_date= #{currentDay} AND jcm.delete_flag=0 AND jcm.camera_id IS NOT NULL
UNION ALL
SELECT COUNT(*) AS num
FROM jj_class_meetting jcm
WHERE jcm.current_constr_date=#{currentDay} AND jcm.delete_flag=0 AND jcm.re_assessment_risk_level IN (2,3)
UNION ALL
SELECT COUNT(*) AS num
FROM jj_class_meetting jcm
LEFT JOIN jj_class_metting_info jcmi ON jcmi.class_id = jcm.id
WHERE jcm.current_constr_date=#{currentDay} AND jcm.delete_flag=0 AND jcm.re_assessment_risk_level = 4 AND (INSTR(jcmi.work_content,'起重机') > 0 OR INSTR(jcmi.work_content,'跨越架') > 0)
UNION ALL
SELECT COUNT(*) AS num
FROM t_notice_voi
WHERE create_time = #{currentDay} AND sup_type = '1' AND is_flag = '0' AND level_id IN ('严重违章','一般违章') AND status NOT IN ('7','8','9')
</select>
<!--问题整改回复情况-->
<select id="getVioRectList" resultType="java.util.Map">
SELECT #{currentDay} AS currentDay,
tnv.ser_no AS serNo,
so.city_name AS orgName,
CASE WHEN tnv.status = '1' THEN '未整改' ELSE '已整改' END AS status
FROM t_notice_voi tnv
LEFT JOIN sys_org so ON tnv.org = so.org_id
WHERE tnv.create_time = #{currentDay} AND tnv.sup_type = '1' AND tnv.is_flag = '0' AND tnv.level_id IN ('严重违章','一般违章') AND status NOT IN ('7','8','9')
ORDER BY tnv.org
</select>
<!--关键措施照片上传和日报质量评价情况-->
<select id="getDailyData"
resultType="com.sercurityControl.proteam.dutyTask.domain.DailyDutyReportVo$DataVo3">
SELECT so.org_id AS orgId,
so.city_name AS orgName,
IFNULL(A.num,0) AS num,
0 AS num2,
'0' AS rate,
IF(so.org_id = '12Z0' OR IFNULL(B.num,0) > 0,'优','差') AS quality
FROM sys_org so
LEFT JOIN (
SELECT COUNT(*) AS num,jcm.build_unit_code AS orgId
FROM jj_class_meetting jcm
WHERE jcm.current_constr_date=#{currentDay} AND jcm.delete_flag=0 AND jcm.re_assessment_risk_level IN (2,3)
GROUP BY jcm.build_unit_code
) A ON A.orgId = so.org_id
LEFT JOIN (
SELECT COUNT(*) AS num,tcdr.org_id AS orgId
FROM tb_city_daily_report_backups tcdr
WHERE tcdr.current_day=#{currentDay} AND tcdr.del_status='1' AND tcdr.store_status IN ('1','2','3')
GROUP BY tcdr.org_id
) B ON B.orgId = so.org_id
ORDER BY IFNULL(A.num,0) DESC
</select>
<!--查询是否已经存在日报数据-->
<select id="isExist" resultType="java.lang.Integer">
SELECT COUNT(*) AS num
FROM tb_city_daily_report_backups
WHERE current_day= #{currentDay} AND org_id= #{orgId} AND del_status='1'
</select>
<!--查询配置的下载类型-->
<select id="getDailyDownType" resultType="java.lang.String">
SELECT sd2.name
FROM sys_dist sd
LEFT JOIN sys_dist sd2 ON sd2.p_id = sd.id AND sd2.is_flag = '0'
WHERE sd.code = 'daily_type' AND sd.is_flag = '0' AND sd2.name IS NOT NULL
</select>
<!--日报-施工单位-->
<select id="getDailyUnit" resultType="java.lang.String">
SELECT sd2.name
FROM sys_dist sd
LEFT JOIN sys_dist sd2 ON sd2.p_id = sd.id AND sd2.is_flag = '0'
WHERE sd.code = 'daily_unit' AND sd.is_flag = '0' AND sd2.name IS NOT NULL
</select>
<!--获取地市申请退回的日报数据-->
<select id="getApplyBackData"
resultType="com.sercurityControl.proteam.dutyTask.domain.CityDailyApplyBackVo">
SELECT id,
so.city_name AS orgName,
tcdr.current_day AS currentDay,
tcdr.store_status AS storeStatus
FROM tb_city_daily_report_backups tcdr
LEFT JOIN sys_org so ON so.org_id = tcdr.org_id
WHERE tcdr.current_day= CURRENT_DATE AND tcdr.del_status='1' AND tcdr.store_status = '2'
</select>
<!--获取地市申请退回的日报数量-->
<select id="getApplyBackDataNum" resultType="java.lang.Integer">
SELECT COUNT(*) AS num
FROM tb_city_daily_report_backups tcdr
WHERE tcdr.current_day= CURRENT_DATE AND tcdr.del_status='1' AND tcdr.store_status = '2'
</select>
<!--获取地市-->
<select id="getOrgs" resultType="java.util.Map">
SELECT org_id AS orgId,city_name AS orgName,'0' AS num FROM sys_org WHERE org_id != '12Z0'
</select>
</mapper>