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.
367 lines
15 KiB
367 lines
15 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.hisense.hiatmp.server_api.mapper.HighDangerMapper"> |
|
|
|
|
|
<select id="getStatusCounts" resultType="com.hisense.hiatmp.model.common.HighDangerBaseNum"> |
|
SELECT 'Unconfirmed' AS status, SUM(CASE WHEN hdb.status = '0' THEN 1 ELSE 0 END) AS count |
|
FROM tht_hidden_danger_base hdb |
|
LEFT JOIN tht_hidden_danger_road hdr |
|
ON hdb.business_id = hdr.business_id AND hdb.pc_count = hdr.pc_count |
|
LEFT JOIN department dp ON hdb.handle_dept = dp.cdepartmentid |
|
LEFT JOIN enum_type et ON et.ENUMTYPEID = '6601' AND et.enumvalue = hdb.status |
|
WHERE hdb.handle_dept = #{cdepartmentid} |
|
|
|
UNION ALL |
|
|
|
SELECT 'UnderInvestigation' AS status, SUM(CASE WHEN hdb.status = '10' THEN 1 ELSE 0 END) AS count |
|
FROM tht_hidden_danger_base hdb |
|
LEFT JOIN tht_hidden_danger_road hdr |
|
ON hdb.business_id = hdr.business_id AND hdb.pc_count = hdr.pc_count |
|
LEFT JOIN department dp ON hdb.handle_dept = dp.cdepartmentid |
|
LEFT JOIN enum_type et ON et.ENUMTYPEID = '6601' AND et.enumvalue = hdb.status |
|
WHERE hdb.handle_dept = #{cdepartmentid} |
|
|
|
UNION ALL |
|
|
|
SELECT 'InGovernance' AS status, SUM(CASE WHEN hdb.status = '20' THEN 1 ELSE 0 END) AS count |
|
FROM tht_hidden_danger_base hdb |
|
LEFT JOIN tht_hidden_danger_road hdr |
|
ON hdb.business_id = hdr.business_id AND hdb.pc_count = hdr.pc_count |
|
LEFT JOIN department dp ON hdb.handle_dept = dp.cdepartmentid |
|
LEFT JOIN enum_type et ON et.ENUMTYPEID = '6601' AND et.enumvalue = hdb.status |
|
WHERE hdb.handle_dept = #{cdepartmentid} |
|
|
|
UNION ALL |
|
|
|
SELECT 'Tracking' AS status, SUM(CASE WHEN hdb.status = '30' THEN 1 ELSE 0 END) AS count |
|
FROM tht_hidden_danger_base hdb |
|
LEFT JOIN tht_hidden_danger_road hdr |
|
ON hdb.business_id = hdr.business_id AND hdb.pc_count = hdr.pc_count |
|
LEFT JOIN department dp ON hdb.handle_dept = dp.cdepartmentid |
|
LEFT JOIN enum_type et ON et.ENUMTYPEID = '6601' AND et.enumvalue = hdb.status |
|
WHERE hdb.handle_dept = #{cdepartmentid} |
|
|
|
UNION ALL |
|
|
|
SELECT 'Finished' AS status, SUM(CASE WHEN hdb.status = '40' THEN 1 ELSE 0 END) AS count |
|
FROM tht_hidden_danger_base hdb |
|
LEFT JOIN tht_hidden_danger_road hdr |
|
ON hdb.business_id = hdr.business_id AND hdb.pc_count = hdr.pc_count |
|
LEFT JOIN department dp ON hdb.handle_dept = dp.cdepartmentid |
|
LEFT JOIN enum_type et ON et.ENUMTYPEID = '6601' AND et.enumvalue = hdb.status |
|
WHERE hdb.handle_dept = #{cdepartmentid} |
|
|
|
UNION ALL |
|
|
|
SELECT 'NonHazard' AS status, SUM(CASE WHEN hdb.status = '50' THEN 1 ELSE 0 END) AS count |
|
FROM tht_hidden_danger_base hdb |
|
LEFT JOIN tht_hidden_danger_road hdr |
|
ON hdb.business_id = hdr.business_id AND hdb.pc_count = hdr.pc_count |
|
LEFT JOIN department dp ON hdb.handle_dept = dp.cdepartmentid |
|
LEFT JOIN enum_type et ON et.ENUMTYPEID = '6601' AND et.enumvalue = hdb.status |
|
WHERE hdb.handle_dept = #{cdepartmentid} |
|
|
|
UNION ALL |
|
|
|
SELECT DISTINCT 'MonthReport' AS status, |
|
SUM(CASE |
|
-- WHEN TO_TIMESTAMP(hdb.pc_end_time, 'DD/MM/YYYY HH24:MI:SS') > |
|
WHEN hdb.pc_end_time > |
|
DATE_TRUNC('MONTH', CURRENT_DATE) THEN 1 |
|
ELSE 0 END) AS count |
|
FROM tht_hidden_danger_base hdb |
|
LEFT JOIN tht_hidden_danger_road hdr |
|
ON |
|
hdb.business_id = hdr.business_id AND hdb.pc_count = hdr.pc_count |
|
LEFT JOIN department dp ON hdb.handle_dept = dp.cdepartmentid |
|
LEFT JOIN enum_type et ON et.ENUMTYPEID = '6601' AND et.enumvalue = hdb.status |
|
WHERE hdb.handle_dept = #{cdepartmentid} |
|
UNION ALL |
|
SELECT DISTINCT 'Dying' AS status, |
|
SUM(CASE |
|
WHEN |
|
hdb.pc_end_time > |
|
CURRENT_TIMESTAMP - INTERVAL '3 days' |
|
and |
|
hdb.pc_end_time <= |
|
CURRENT_TIMESTAMP |
|
THEN 1 ELSE 0 END) AS count |
|
FROM tht_hidden_danger_base hdb |
|
LEFT JOIN tht_hidden_danger_road hdr |
|
ON |
|
hdb.business_id = hdr.business_id AND hdb.pc_count = hdr.pc_count |
|
LEFT JOIN department dp ON hdb.handle_dept = dp.cdepartmentid |
|
LEFT JOIN enum_type et ON et.ENUMTYPEID = '6601' AND et.enumvalue = hdb.status |
|
WHERE hdb.handle_dept = #{cdepartmentid} |
|
UNION ALL |
|
SELECT DISTINCT 'Delay' AS status, |
|
SUM(CASE |
|
WHEN |
|
hdb.pc_end_time > |
|
CURRENT_TIMESTAMP |
|
THEN 1 |
|
ELSE 0 END) AS count |
|
FROM tht_hidden_danger_base hdb |
|
LEFT JOIN tht_hidden_danger_road hdr |
|
ON |
|
hdb.business_id = hdr.business_id AND hdb.pc_count = hdr.pc_count |
|
LEFT JOIN department dp ON hdb.handle_dept = dp.cdepartmentid |
|
LEFT JOIN enum_type et ON et.ENUMTYPEID = '6601' AND et.enumvalue = hdb.status |
|
WHERE hdb.handle_dept = #{cdepartmentid} |
|
</select> |
|
|
|
<select id="getHigDangerDealt" resultType="com.hisense.hiatmp.model.common.HighDangerBase"> |
|
SELECT * |
|
FROM tht_hidden_danger_base hdb |
|
LEFT JOIN tht_hidden_danger_road hdr ON hdb.business_id = hdr.business_id |
|
AND hdb.pc_count = hdr.pc_count |
|
LEFT JOIN department dp ON hdb.handle_dept = dp.cdepartmentid |
|
LEFT JOIN enum_type et ON et.ENUMTYPEID = '6601' |
|
AND et.enumvalue = hdb.status |
|
WHERE hdb.handle_dept = #{cdepartmentid} |
|
<if test="status != null and status != ''"> |
|
AND hdb.status = #{status} |
|
</if> |
|
-- ORDER BY hdb.PC_END_TIME::timestamp DESC |
|
ORDER BY |
|
CASE |
|
WHEN hdb.PC_END_TIME IS NULL THEN 1 |
|
ELSE 0 |
|
END, hdb.PC_END_TIME DESC |
|
</select> |
|
|
|
<select id="getHigDangerDying" resultType="com.hisense.hiatmp.model.common.HighDangerBase"> |
|
SELECT |
|
* |
|
FROM |
|
tht_hidden_danger_base hdb |
|
LEFT JOIN tht_hidden_danger_road hdr ON hdb.business_id = hdr.business_id |
|
AND hdb.pc_count = hdr.pc_count |
|
LEFT JOIN department dp ON hdb.handle_dept = dp.cdepartmentid |
|
LEFT JOIN enum_type et ON et.ENUMTYPEID = '6601' |
|
AND et.enumvalue = hdb.status |
|
WHERE |
|
hdb.handle_dept = #{cdepartmentid} |
|
AND TO_TIMESTAMP( hdb.pc_end_time, 'DD/MM/YYYY HH24:MI:SS' ) > CURRENT_TIMESTAMP - INTERVAL '3 days' |
|
<if test="hdb.pc_end_time != null and hdb.pc_end_time != ''"> |
|
AND hdb.pc_end_time != '' |
|
</if> |
|
</select> |
|
|
|
|
|
<select id="getHigDangerDetail" resultType="com.hisense.hiatmp.model.common.HighDangerBase"> |
|
SELECT DISTINCT hdb.*,hdr.coordinate, hdr.coordinate_type |
|
FROM tht_hidden_danger_base hdb |
|
left join tht_hidden_danger_road hdr on hdr.business_id = hdb.business_id |
|
WHERE hdb.business_id = #{businessId} |
|
</select> |
|
|
|
<select id="getHigDangerSearch" resultType="com.hisense.hiatmp.model.common.HighDangerBase"> |
|
SELECT * |
|
FROM tht_hidden_danger_base hdb |
|
WHERE hdb.name like #{search} |
|
</select> |
|
|
|
<select id="getAllSection" resultType="com.hisense.hiatmp.model.common.SectionVO"> |
|
SELECT |
|
section_code, |
|
section_name, |
|
road_code, |
|
width, |
|
length, |
|
area_code, |
|
position |
|
FROM bis_section |
|
</select> |
|
|
|
<select id="getAllCrossing" resultType="com.hisense.hiatmp.model.common.CrossingDTO"> |
|
SELECT |
|
* |
|
FROM bis_crossing |
|
</select> |
|
|
|
|
|
<select id="getRoadInfo" resultType="com.hisense.hiatmp.model.common.HighDangerRoad"> |
|
|
|
SELECT DISTINCT thdb.*, thdr.address, thdr.coordinate |
|
from |
|
tht_hidden_danger_base thdb |
|
left join tht_hidden_danger_road thdr on thdr.business_id = thdb.business_id |
|
where |
|
thdb.business_id = #{businessId} |
|
</select> |
|
|
|
<select id="getImportDanger" resultType="com.hisense.hiatmp.model.common.ImportDangerDTO"> |
|
SELECT * |
|
from tht_hidden_scenes; |
|
</select> |
|
|
|
<update id="saveSection"> |
|
update tht_hidden_danger_road thdr |
|
set |
|
address = #{address}, |
|
coordinate = #{coordinate} |
|
where business_id = #{businessId} |
|
</update> |
|
|
|
<update id="bindRoad"> |
|
update tht_hidden_danger_road set |
|
section_code = #{sectionCode} |
|
where business_id = #{businessId}; |
|
</update> |
|
|
|
<update id="saveCrossing"> |
|
update tht_hidden_danger_road thdr |
|
set |
|
address = #{address}, |
|
coordinate = #{coordinate} |
|
where business_id = #{businessId} |
|
</update> |
|
|
|
<select id="getImportDangerInfo" resultType="com.hisense.hiatmp.model.common.ImportDangerInfoDTO"> |
|
SELECT b.* |
|
FROM tht_hidden_scenes a |
|
JOIN tht_scenes_items_relations c ON c.scenesid = a.nid |
|
JOIN tht_hidden_data_collect_config b ON c.itemid = b.itemid |
|
WHERE a.nid = #{nid}; |
|
</select> |
|
|
|
<select id="setApproval" resultType="String"> |
|
UPDATE tht_hidden_danger_base |
|
SET APPROVE_STATUS = 2 |
|
where business_id = #{businessId} RETURNING business_id; |
|
</select> |
|
|
|
<select id="getSectionInfo" resultType="com.hisense.hiatmp.model.common.ThtSectionInfoDTO"> |
|
SELECT * |
|
FROM tht_section_info |
|
where "BUSINESS_ID" = #{businessId} |
|
</select> |
|
|
|
<select id="getSectionTraffic" resultType="com.hisense.hiatmp.model.common.ThtSectionTrafficDTO"> |
|
SELECT * |
|
FROM tht_section_traffic |
|
where "BUSINESS_ID" = #{businessId} |
|
</select> |
|
|
|
<select id="getDangerItems" resultType="com.hisense.hiatmp.model.common.ThtDangerItems"> |
|
SELECT * |
|
FROM tht_danger_items |
|
</select> |
|
|
|
<select id="isExtraExistence" resultType="com.hisense.hiatmp.model.common.ThtHiddenDangerExtra"> |
|
SELECT * FROM tht_hidden_danger_road_info where business_id = #{businessId} |
|
</select> |
|
|
|
<insert id="insertSectionInfo"> |
|
insert into tht_section_info |
|
values (nextval('test_id_seq'), |
|
#{businessId}, |
|
#{roadType}, |
|
#{roadWidth}, |
|
#{laneCount}, |
|
#{roadStructure}, |
|
#{sideProtec}, |
|
#{centerSeparate}, |
|
#{designSpeed}, |
|
#{limitSpeed}) |
|
RETURNING #{businessId}; |
|
</insert> |
|
|
|
|
|
<update id="updateSectionInfo"> |
|
update tht_section_info |
|
set "ROAD_TYPE" = #{roadType}, |
|
"ROAD_WIDTH" = #{roadWidth}, |
|
"LANE_COUNT" = #{laneCount}, |
|
"ROAD_STRUCTURE" = #{roadStructure}, |
|
"SIDE_PROTEC" = #{sideProtec}, |
|
"CENTER_SEPARATE" = #{centerSeparate}, |
|
"DESIGN_SPEED" = #{designSpeed}, |
|
"LIMIT_SPEED" = #{limitSpeed} |
|
where "BUSINESS_ID" = #{businessId} |
|
</update> |
|
|
|
<insert id="insertSectionTraffic"> |
|
insert into tht_section_traffic |
|
values (nextval('test_id_seq1'), |
|
#{businessId}, |
|
#{passingTrend}, |
|
#{maxTraffic}, |
|
#{peakTraffic}, |
|
#{peakHours}, |
|
#{normalTraffic}, |
|
#{largeVehicleRate}, |
|
#{vehicleTraffic}, |
|
#{lastModeUser}, |
|
#{lastModeDate}) |
|
</insert> |
|
|
|
<update id="updateSectionTraffic"> |
|
update tht_section_traffic |
|
set "PASSING_TREND" = #{passingTrend}, |
|
"MAX_TRAFFIC" = #{maxTraffic}, |
|
"PEAK_TRAFFIC" = #{peakTraffic}, |
|
"PEAK_HOURS" = #{peakHours}, |
|
"NORMAL_TRAFFIC" = #{normalTraffic}, |
|
"LARGE_VEHICLE_RATE" = #{largeVehicleRate}, |
|
"NONVEHICLE_TRAFFIC" = #{vehicleTraffic}, |
|
"LAST_MOD_USER" = #{lastModeUser}, |
|
"LAST_MOD_DATE" = #{lastModeDate} |
|
where "BUSINESS_ID" = #{businessId} |
|
</update> |
|
|
|
<update id="updateTemporary"> |
|
update tht_hidden_danger_base |
|
set status = #{temporary} |
|
where business_id = #{businessId} |
|
</update> |
|
|
|
<insert id="saveHiddenDataCollectConfig"> |
|
INSERT INTO tht_hidden_data_collect_config_extra (nid, itemid, "order", type, name, standar, unit, business_id) |
|
VALUES (nextval('test_id_seq2'), #{itemid}, #{order}, #{type}, #{name}, #{standar}, #{unit},#{businessId}) |
|
</insert> |
|
|
|
<insert id="saveDangerExtra"> |
|
INSERT INTO tht_hidden_danger_road_info (nid, business_id, big_category, small_category, hd_term, hd_desc, |
|
pc_count,hd_pic,hd_info) |
|
VALUES (#{nid}, #{businessId}, #{bigCategory}, #{smallCategory}, #{hdTerm}, |
|
#{hdDesc}, #{pcCount},#{hdPic},#{hdInfo}) |
|
</insert> |
|
|
|
|
|
<insert id="saveRoad"> |
|
insert into bis_road ("road_code","road_name","position") values(#{roadCode},#{roadName},#{position}) |
|
</insert> |
|
|
|
<delete id="deleteRoadInfo"> |
|
delete from tht_hidden_danger_road_info where business_id = #{businessId} |
|
</delete> |
|
|
|
<delete id="deleteThtHiddenDataCollectConfigExtra"> |
|
delete from tht_hidden_data_collect_config_extra where business_id = #{businessId} |
|
</delete> |
|
|
|
<insert id="saveThtHiddenDataCollectConfigExtra"> |
|
insert into |
|
tht_hidden_data_collect_config_extra |
|
("nid","itemid","order","type","name","standar","unit","business_id","scenes_id","pc_count") |
|
values |
|
(nextval('test_id_seq2'),#{itemid},#{order},#{type},#{name},#{standar},#{unit},#{businessId},#{scenesId},#{pcCount}) |
|
</insert> |
|
|
|
<select id="getImportDangerDisplay" resultType="com.hisense.hiatmp.model.common.ThtHiddenDataCollectConfigExtra"> |
|
select * from tht_hidden_data_collect_config_extra where business_id = #{businessId} |
|
</select> |
|
|
|
<select id="getImportDangerDisplayItem" resultType="com.hisense.hiatmp.model.common.ImportDangerDTO"> |
|
SELECT DISTINCT s.* |
|
FROM tht_hidden_data_collect_config_extra e |
|
INNER JOIN tht_hidden_scenes s ON e.scenes_id = s.nid |
|
where e.business_id = #{businessId} |
|
</select> |
|
|
|
</mapper> |