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.
460 lines
18 KiB
460 lines
18 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' or hdb.status = '99' 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} and hdb.status = '10' |
|
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} and hdb.status = '10' |
|
</select> |
|
|
|
<select id="getHigDangerDealt" resultType="com.hisense.hiatmp.model.common.HighDangerBase"> |
|
SELECT hdb.*,hdr.pc_type,hdr.pc_end_time as road_pc_end_time |
|
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 == 0"> |
|
AND hdb.status in ('0','99') |
|
</if>--> |
|
<if test="status != null"> |
|
AND hdb.status = #{status} |
|
</if> |
|
<if test="search != null and search != ''"> |
|
AND hdb.name like concat(concat('%',#{search}),'%') |
|
</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" parameterType="com.hisense.hiatmp.model.common.SectionVO" |
|
resultType="com.hisense.hiatmp.model.common.SectionVO"> |
|
SELECT |
|
section_code, |
|
section_name, |
|
road_code, |
|
width, |
|
length, |
|
area_code, |
|
position |
|
FROM bis_section |
|
where 1 = 1 |
|
<if test="search != null and search != ''"> |
|
AND section_name like concat(concat('%',#{search}),'%') |
|
</if> |
|
<if test="position != null and position != ''"> |
|
AND position like concat(concat('%',#{position}),'%') |
|
</if> |
|
</select> |
|
|
|
<select id="getAllCrossing" parameterType="com.hisense.hiatmp.model.common.CrossingDTO" |
|
resultType="com.hisense.hiatmp.model.common.CrossingDTO"> |
|
SELECT |
|
* |
|
FROM bis_crossing |
|
where 1 = 1 |
|
<if test="search != null and search != ''"> |
|
AND crossing_name like concat(concat('%',#{search}),'%') |
|
</if> |
|
<if test="lonMin != null"> |
|
AND longitude >= #{lonMin} |
|
</if> |
|
<if test="lonMax != null"> |
|
AND longitude <= #{lonMax} |
|
</if> |
|
<if test="latMin != null"> |
|
AND latitude >= #{latMin} |
|
</if> |
|
<if test="latMax != null"> |
|
AND latitude <= #{latMax} |
|
</if> |
|
</select> |
|
|
|
|
|
<select id="getRoadInfo" resultType="com.hisense.hiatmp.model.common.HighDangerRoad"> |
|
|
|
SELECT DISTINCT thdb.*, thdr.address, thdr.section_code, thdr.if_cross, 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="isRoadExist" resultType="int"> |
|
SELECT DISTINCT * |
|
from tht_hidden_danger_road |
|
where business_id = #{businessId} |
|
</select> |
|
|
|
<insert id="insertRoad"> |
|
insert into tht_hidden_danger_road (nid, business_id) |
|
values (#{uuid}, #{businessId}) |
|
</insert> |
|
|
|
<select id="getImportDanger" resultType="com.hisense.hiatmp.model.common.ImportDangerDTO"> |
|
SELECT DISTINCT * |
|
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="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 DISTINCT * |
|
FROM tht_danger_items |
|
</select> |
|
|
|
<select id="isExtraExistence" resultType="com.hisense.hiatmp.model.common.HiddenDangerDTO"> |
|
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}, |
|
#{nonvehicleTraffic}, |
|
#{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" = #{nonvehicleTraffic}, |
|
"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, pc_type) |
|
VALUES (#{nid}, #{businessId}, #{bigCategory}, #{smallCategory}, #{hdTerm}, |
|
#{hdDesc}, #{pcCount}, #{hdPic}, #{hdInfo}, #{pcType}) |
|
</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", |
|
"danger_id") |
|
values (nextval('test_id_seq2'), #{itemid}, #{order}, #{type}, #{name}, #{standar}, #{unit}, #{businessId}, |
|
#{scenesId}, #{pcCount}, #{dangerId}) |
|
</insert> |
|
|
|
<select id="getImportDangerDisplay" resultType="com.hisense.hiatmp.model.common.ThtHiddenDataCollectConfigExtra"> |
|
select * from tht_hidden_data_collect_config_extra where business_id = #{businessId} |
|
<if test="dangerId != null"> |
|
and danger_id = #{dangerId} |
|
</if> |
|
</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> |
|
|
|
<select id="getImportDangerItems" resultType="com.hisense.hiatmp.model.common.ThtDangerItems"> |
|
select DISTINCT r.*, i.* |
|
from tht_scenes_danger_relation r |
|
left join tht_danger_items i on r.dangerid = i.id |
|
where r.scenesid = #{nid} |
|
order by r.order |
|
</select> |
|
|
|
<select id="getUserHiddenDangerList" resultType="com.hisense.hiatmp.model.common.HiddenDangerDTO"> |
|
SELECT |
|
* |
|
FROM |
|
tht_hidden_danger_road_info |
|
where |
|
business_id = #{businessId} |
|
and |
|
pc_type = #{pcType} |
|
<if test="hdTerm != null and hdTerm != ''"> |
|
AND hd_term = #{hdTerm} |
|
</if> |
|
|
|
</select> |
|
|
|
<select id="getDangerProblem" resultType="String"> |
|
SELECT DISTINCT itemname |
|
FROM tht_danger_items |
|
where id = #{id} |
|
</select> |
|
|
|
<update id="HighDangerSaveStatus"> |
|
update tht_hidden_danger_road |
|
set pc_type = #{pcType} |
|
where business_id = #{businessId} |
|
</update> |
|
|
|
|
|
</mapper> |