update inspection_hidden_danger set valid_flag = 0 , update_time = #{inspectionHiddenDanger.updateTime},update_by = #{inspectionHiddenDanger.updateBy}
where self_inspection_item_id = #{inspectionHiddenDanger.selfInspectionItemId}
update inspection_hidden_danger
set valid_flag = 0
where
id in
#{id}
SELECT
l.*
FROM
(
SELECT
t.*,
( CASE WHEN t.unRectifyCount = t.hdTocalCount THEN - 1 WHEN t.rectifyCount = t.hdTocalCount THEN 2 ELSE 1 END ) rectificationStatus
FROM
(
SELECT
s.*,
count( h.`status` = - 1 OR NULL ) unRectifyCount,
count( h.`status` = 1 OR NULL ) rectifyCount,
count( h.`status` ) hdTocalCount,
count( h.LEVEL = 1 OR NULL ) sameAsCount,
count( h.LEVEL = 2 OR NULL ) majorCount
FROM
safety_self_inspection s
LEFT JOIN inspection_hidden_danger h ON s.id = h.self_inspection_id
WHERE
s.valid_flag = 1
AND h.valid_flag = 1
AND h.id IS NOT NULL
GROUP BY
s.id
) t
) l
LEFT JOIN company AS co ON l.checked_company_id = co.id
WHERE
1 =1
and l.inspection_name like concat("%",#{params.inspectionName},"%")
and l.checked_company_id = #{params.checkedCompanyId}
and l.checked_company_name like concat("%",#{params.checkedCompanyName},"%")
and l.flag = #{params.flag}
and l.rectificationStatus = #{params.rectificationStatus}
and l.inspection_time = ]]> #{params.inspectionStartTime}
and l.inspection_time #{params.inspectionEndTime}
and co.province = #{params.province}
and co.city = #{params.city}
and co.area = #{params.area}
ORDER BY l.create_time desc
SELECT
h.*,
i.element_a,
a.`name` as elementAname,
i.element_b,
b.`name` as elementBname,
i.element_c ,
c.`name` as elementCname,
i.standardization_requirements,
i.enterprise_standard,
i.review_method,
i.veto
FROM
inspection_hidden_danger h
LEFT JOIN safety_self_inspection_item s ON h.self_inspection_item_id = s.id
LEFT JOIN safety_inspection_item i ON s.safety_inspection_item_id = i.id
left join element_management a on a.id = i.element_a
left join element_management b on b.id = i.element_b
left join element_management c on c.id = i.element_c
where h.valid_flag = 1
and h.self_inspection_id = #{selfInspectionId}
select
l.checked_company_id as companyId,
count(l.id) as checkTotal,
sum(l.unRectifyTotal) as sUnReTotal,
sum(l.reTotal) as sReTotal,
sum(l.hdTocal) as sHdTotal,
sum(l.saTotal) as sSaTotal,
sum(l.maTotal) as sMaTotal,
sum(l.saReTotal) as sSaReTotal,
sum(l.maReTotal) as sMaReTotal
from (
SELECT
s.id,
s.checked_company_id,
t.*
FROM
safety_self_inspection s
INner JOIN company c on s.checked_company_id = c.id
LEFT JOIN (
SELECT
h.self_Inspection_id,
count( h.`status` = - 1 OR NULL ) unRectifyTotal,
count( h.`status` = 1 OR NULL ) reTotal,
count( h.`status` ) hdTocal,
count( h.LEVEL = 1 OR NULL ) saTotal,
count( h.LEVEL = 2 OR NULL ) maTotal,
count( h.LEVEL = 1 AND h.`status` = 1 OR NULL ) saReTotal,
count( h.LEVEL = 2 AND h.`status` = 1 OR NULL ) maReTotal
FROM
inspection_hidden_danger h
WHERE
h.valid_flag = 1
GROUP BY
h.self_Inspection_id
) t ON t.self_Inspection_id = s.id
WHERE
s.valid_flag = 1
and s.flag = 2
and s.inspection_time = ]]> #{query.startTime}
and s.inspection_time #{query.endTime}
and c.area = #{query.area}
) l
GROUP BY l.checked_company_id