|
|
@ -315,4 +315,79 @@ |
|
|
#{patrolPointId} |
|
|
#{patrolPointId} |
|
|
</foreach> |
|
|
</foreach> |
|
|
</delete> |
|
|
</delete> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<resultMap type="PointStatsVo" id="PointStatsResult"> |
|
|
|
|
|
<result property="inspectionPointTotal" column="inspect_point_total"/> |
|
|
|
|
|
<result property="inspectionPointAnomalyCount" column="inspectionPointAnomalyCount"/> |
|
|
|
|
|
</resultMap> |
|
|
|
|
|
<select id="getInspectPointStats" parameterType="PointStatsVo" |
|
|
|
|
|
resultMap="PointStatsResult"> |
|
|
|
|
|
SELECT COUNT(*) AS inspectionPointAnomalyCount |
|
|
|
|
|
FROM ( |
|
|
|
|
|
SELECT |
|
|
|
|
|
ra.objectId, |
|
|
|
|
|
bp.patrol_point_id |
|
|
|
|
|
FROM result_analysis ra |
|
|
|
|
|
LEFT JOIN basedata_patrolpoint bp ON ra.objectId = bp.patrol_point_id |
|
|
|
|
|
<where> |
|
|
|
|
|
ra.point_status != 1 |
|
|
|
|
|
AND bp.patrol_point_id IS NOT NULL |
|
|
|
|
|
<if test="startTime != null ">and ra.create_time > CONCAT(#{startTime}, ' 00:00:00')</if> |
|
|
|
|
|
<if test="endTime != null ">and ra.create_time < CONCAT(#{endTime}, ' 23:59:59')</if> |
|
|
|
|
|
</where> |
|
|
|
|
|
GROUP BY ra.objectId, bp.patrol_point_id |
|
|
|
|
|
) AS temp_table; |
|
|
|
|
|
</select> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<resultMap id="InspectionTaskResultMap" type="PointLatestResultVo"> |
|
|
|
|
|
<id property="id" column="id" /> |
|
|
|
|
|
<result property="patroldeviceCode" column="patroldevice_code" /> |
|
|
|
|
|
<result property="patroldeviceName" column="patroldevice_name" /> |
|
|
|
|
|
<result property="taskCode" column="task_code" /> |
|
|
|
|
|
<result property="taskName" column="task_name" /> |
|
|
|
|
|
<result property="taskPatrolledId" column="task_patrolled_id" /> |
|
|
|
|
|
<result property="deviceId" column="device_id" /> |
|
|
|
|
|
<result property="deviceName" column="device_name" /> |
|
|
|
|
|
<result property="mainDevId" column="main_dev_id" /> |
|
|
|
|
|
<result property="mainDevName" column="main_dev_name" /> |
|
|
|
|
|
<result property="componentId" column="component_id" /> |
|
|
|
|
|
<result property="componentName" column="component_name" /> |
|
|
|
|
|
<result property="value" column="value" /> |
|
|
|
|
|
<result property="unit" column="unit" /> |
|
|
|
|
|
<result property="recognitionType" column="recognition_type" /> |
|
|
|
|
|
<result property="time" column="time" /> |
|
|
|
|
|
<result property="fileType" column="file_type" /> |
|
|
|
|
|
<result property="filePath" column="file_path" /> |
|
|
|
|
|
<result property="baseFilePath" column="base_file_path" /> |
|
|
|
|
|
<result property="rectangle" column="rectangle" /> |
|
|
|
|
|
<result property="valid" column="valid" /> |
|
|
|
|
|
</resultMap> |
|
|
|
|
|
<select id="pointLatestResult" parameterType="PointLatestResultVo" |
|
|
|
|
|
resultMap="InspectionTaskResultMap"> |
|
|
|
|
|
SELECT bd.device_name main_dev_name,bd.device_id main_dev_id ,bp.patrol_point_name device_name,bp.patrol_point_id device_id, |
|
|
|
|
|
bec.channel_code patroldevice_code,bec.channel_name patroldevice_name, |
|
|
|
|
|
latest_pr.task_code,latest_pr.task_name,latest_pr.line_id task_patrolled_id, |
|
|
|
|
|
bpp.patrol_point_preset_id device_id, bpp.preset_name device_name, |
|
|
|
|
|
latest_pr.value ,latest_pr.value_unit unit,latest_pr.recognition_type,latest_pr.time, |
|
|
|
|
|
latest_pr.file_type,latest_pr.file_path,latest_pr.rectangle,latest_pr.valid |
|
|
|
|
|
-- #bec.*, bpp.*, latest_ra.*,latest_pr.* |
|
|
|
|
|
FROM basedata_eqpbook_channel bec |
|
|
|
|
|
LEFT JOIN basedata_patrolpoint_preset bpp ON bec.channel_code = bpp.channel_code |
|
|
|
|
|
left join basedata_patrolpoint bp on bp.patrol_point_id = bpp.patrol_point_id |
|
|
|
|
|
left join basedata_device bd on bp.main_device_id = bd.device_id |
|
|
|
|
|
LEFT JOIN ( SELECT pr.* |
|
|
|
|
|
FROM patrol_result pr |
|
|
|
|
|
INNER JOIN ( |
|
|
|
|
|
SELECT device_id, MAX(time) AS max_create_time |
|
|
|
|
|
FROM patrol_result |
|
|
|
|
|
GROUP BY device_id |
|
|
|
|
|
) pr2 ON pr.device_id = pr2.device_id AND pr.time = pr2.max_create_time) latest_pr ON latest_pr.device_id = bpp.patrol_point_id |
|
|
|
|
|
<where> |
|
|
|
|
|
bpp.patrol_point_id IS NOT NULL AND latest_pr.line_id IS NOT NULL |
|
|
|
|
|
<if test="patroldeviceCode != null ">and bpp.channel_code = #{patroldeviceCode}</if> |
|
|
|
|
|
</where> |
|
|
|
|
|
</select> |
|
|
|
|
|
|
|
|
</mapper> |
|
|
</mapper> |