Browse Source

桩号归属路段数据处理,应急人员导出重复,感知事件统计横坐标数据返回

develop
wangsixiang 1 year ago
parent
commit
cb4d38c5ed
  1. 8
      zc-business/src/main/java/com/zc/business/controller/DcRoadSectionController.java
  2. 4
      zc-business/src/main/java/com/zc/business/domain/DcEmployees.java
  3. 7
      zc-business/src/main/java/com/zc/business/mapper/DcRoadSectionMapper.java
  4. 2
      zc-business/src/main/java/com/zc/business/service/IDcRoadSectionService.java
  5. 25
      zc-business/src/main/java/com/zc/business/service/impl/DcRoadSectionServiceImpl.java
  6. 75
      zc-business/src/main/java/com/zc/business/service/impl/DcShiftsServiceImpl.java
  7. 98
      zc-business/src/main/resources/mapper/business/DcPerceivedEventsWarningMapper.xml
  8. 16
      zc-business/src/main/resources/mapper/business/DcRoadSectionMapper.xml

8
zc-business/src/main/java/com/zc/business/controller/DcRoadSectionController.java

@ -128,4 +128,12 @@ public class DcRoadSectionController extends BaseController
public AjaxResult roadList(){ public AjaxResult roadList(){
return AjaxResult.success(dcRoadSectionService.selectRoadList()); return AjaxResult.success(dcRoadSectionService.selectRoadList());
} }
//处理桩号归属的路段id
@PostMapping("/selectMileage")
public AjaxResult selectMileage(){
dcRoadSectionService.selectMileage();
return AjaxResult.success();
}
} }

4
zc-business/src/main/java/com/zc/business/domain/DcEmployees.java

@ -21,12 +21,12 @@ public class DcEmployees extends BaseEntity
/** $column.columnComment */ /** $column.columnComment */
@ApiModelProperty("所属岗位") @ApiModelProperty("所属岗位")
@Excel(name = "所属岗位") // @Excel(name = "所属岗位")
private String postId; private String postId;
/** $column.columnComment */ /** $column.columnComment */
@ApiModelProperty("所属机构") @ApiModelProperty("所属机构")
@Excel(name = "所属机构") // @Excel(name = "所属机构")
private Long organizationId; private Long organizationId;
/** */ /** */

7
zc-business/src/main/java/com/zc/business/mapper/DcRoadSectionMapper.java

@ -3,6 +3,7 @@ package com.zc.business.mapper;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import com.zc.business.domain.DcRoadSection; import com.zc.business.domain.DcRoadSection;
import org.apache.ibatis.annotations.Param;
/** /**
* 辖区路段Mapper接口 * 辖区路段Mapper接口
@ -61,4 +62,10 @@ public interface DcRoadSectionMapper
int deleteDcRoadSectionByIds(Long[] ids); int deleteDcRoadSectionByIds(Long[] ids);
//查询路线id与名称 //查询路线id与名称
List<HashMap<String,Object>> selectRoadList(); List<HashMap<String,Object>> selectRoadList();
//查询桩号里程后的数据(路段)
List<HashMap<String,Object>> selectMileage();
//查询桩号里程后的数据(桩号)
List<HashMap<String,Object>> selectStakeMarkMileage();
//修改桩号归属路段id
int updateStakeMarkRecord(@Param("sectionId") Long sectionId,@Param("stakeMark") String stakeMark);
} }

2
zc-business/src/main/java/com/zc/business/service/IDcRoadSectionService.java

@ -61,4 +61,6 @@ public interface IDcRoadSectionService
int deleteDcRoadSectionById(Long id); int deleteDcRoadSectionById(Long id);
//查询路线id与名称 //查询路线id与名称
List<HashMap<String,Object>> selectRoadList(); List<HashMap<String,Object>> selectRoadList();
//处理桩号归属的路段id
void selectMileage();
} }

25
zc-business/src/main/java/com/zc/business/service/impl/DcRoadSectionServiceImpl.java

@ -147,4 +147,29 @@ public class DcRoadSectionServiceImpl implements IDcRoadSectionService
public List<HashMap<String, Object>> selectRoadList() { public List<HashMap<String, Object>> selectRoadList() {
return dcRoadSectionMapper.selectRoadList(); return dcRoadSectionMapper.selectRoadList();
} }
//处理桩号归属的路段id
@Override
public void selectMileage() {
List<HashMap<String, Object>> sectionListValue = dcRoadSectionMapper.selectMileage();//路段集合
List<HashMap<String, Object>> stakeMarkListValue = dcRoadSectionMapper.selectStakeMarkMileage();//桩号集合
for (HashMap<String,Object> stakeMarkList:stakeMarkListValue ){
String stakeMarkRecord = stakeMarkList.get("startStakeMark").toString();//桩号
String stakeMarkString = stakeMarkList.get("stakeMark").toString();//桩号里程
Integer stakeMark = Integer.valueOf(stakeMarkString);
for (HashMap<String,Object>sectionList:sectionListValue){
String startStakeMarkString = sectionList.get("startStakeMark").toString();//开始
Integer startStakeMark = Integer.valueOf(startStakeMarkString);
String endStakeMarkString = sectionList.get("endStakeMark").toString();//结束
Integer endStakeMark = Integer.valueOf(endStakeMarkString);
if (startStakeMark<=stakeMark&&stakeMark<=endStakeMark){
Long sectionId = (Long) sectionList.get("id");
dcRoadSectionMapper.updateStakeMarkRecord(sectionId,stakeMarkRecord);
}else {
continue;
}
}
}
}
} }

75
zc-business/src/main/java/com/zc/business/service/impl/DcShiftsServiceImpl.java

@ -73,21 +73,39 @@ public class DcShiftsServiceImpl implements IDcShiftsService
@Override @Override
public List<DcShifts> selectDcShiftsList(DcShifts dcShifts) public List<DcShifts> selectDcShiftsList(DcShifts dcShifts)
{ {
String name = org.apache.commons.lang3.StringUtils.isNotBlank(dcShifts.getName())?dcShifts.getName():null;
List<DcShifts> list = dcShiftsMapper.selectDcShiftsList(dcShifts); List<DcShifts> list = dcShiftsMapper.selectDcShiftsList(dcShifts);
for (DcShifts shifts:list ){ for (DcShifts shifts:list ){
String name="";
Date date = shifts.getDate(); Date date = shifts.getDate();
Long station = shifts.getStation(); Long station = shifts.getStation();
if (org.apache.commons.lang3.StringUtils.isNotBlank(dcShifts.getName())){
name=dcShifts.getName();
}
List<DcShiftsList> organizationName = dcShiftsMapper.selectStationDate(station, date,name); List<DcShiftsList> organizationName = dcShiftsMapper.selectStationDate(station, date,name);
shifts.setShiftsList(organizationName); shifts.setShiftsList(organizationName);
} }
return list; return list;
} }
// public List<DcShifts> selectDcShiftsList(DcShifts dcShifts) {
// List<DcShifts> list = dcShiftsMapper.selectDcShiftsList(dcShifts);
//
// // 创建一个映射,用于存储station-date-name到DcShiftsList的映射
// Map<String, List<DcShiftsList>> organizationNameMap = new HashMap<>();
//
// // 一次性获取所有DcShiftsList,并根据station-date-name进行分组
// for (DcShifts shifts : list) {
// Date date = shifts.getDate();
// Long station = shifts.getStation();
// String key = station + "-" + date.getTime() + "-" + (org.apache.commons.lang3.StringUtils.isNotBlank(dcShifts.getName()) ? dcShifts.getName() : "");
// organizationNameMap.put(key, dcShiftsMapper.selectStationDate(station, date, dcShifts.getName()));
// }
// // 设置shifts的shiftsList
// for (DcShifts shifts : list) {
// Date date = shifts.getDate();
// Long station = shifts.getStation();
// String key = station + "-" + date.getTime() + "-" + (org.apache.commons.lang3.StringUtils.isNotBlank(dcShifts.getName()) ? dcShifts.getName() : "");
// shifts.setShiftsList(organizationNameMap.get(key));
// }
//
// return list;
// }
@Override @Override
public List<DcShifts> selectDcShiftsListExcel(DcShifts dcShifts) { public List<DcShifts> selectDcShiftsListExcel(DcShifts dcShifts) {
@ -119,29 +137,30 @@ public class DcShiftsServiceImpl implements IDcShiftsService
if (aLong!=0){ if (aLong!=0){
continue; continue;
} }
dcShifts.setCreateTime(DateUtils.getNowDate());
int shifts = dcShiftsMapper.insertDcShifts(dcShifts);
if (shifts==0){
msg="新增用户信息失败";
throw new ServiceException(msg);
}
DcShiftsRecord dcShiftsRecord = new DcShiftsRecord();
dcShiftsRecord.setOperator(SecurityUtils.getUserId());//操作人员id
dcShiftsRecord.setOperationType("Add");//操作类型
dcShiftsRecord.setOperationTime(DateUtils.getNowDate());//操作时间
dcShiftsRecord.setShiftsDate(dcShifts.getDate());//值班日期
Long employeesIdS = dcShifts.getEmployeesId();//新增人员id
DcEmployees dcEmployees = dcEmployeesMapper.selectDcEmployeesById(employeesIdS);
String name = dcEmployees.getName();//新增人员名称
dcShiftsRecord.setModifyContent("新增值班人员"+name);
dcShifts.setCreateTime(DateUtils.getNowDate());
dcShiftsRecord.setStation(station);//驻点
int shiftsRecord = dcShiftsMapper.insertDcShiftsRecord(dcShiftsRecord);
if (shiftsRecord==0){
msg="操作日志记录失败";
throw new ServiceException(msg);
}
} }
dcShifts.setCreateTime(DateUtils.getNowDate());
int shifts = dcShiftsMapper.insertDcShifts(dcShifts);
if (shifts==0){
msg="新增用户信息失败";
throw new ServiceException(msg);
}
DcShiftsRecord dcShiftsRecord = new DcShiftsRecord();
dcShiftsRecord.setOperator(SecurityUtils.getUserId());//操作人员id
dcShiftsRecord.setOperationType("Add");//操作类型
dcShiftsRecord.setOperationTime(DateUtils.getNowDate());//操作时间
dcShiftsRecord.setShiftsDate(dcShifts.getDate());//值班日期
Long employeesIdS = dcShifts.getEmployeesId();//新增人员id
DcEmployees dcEmployees = dcEmployeesMapper.selectDcEmployeesById(employeesIdS);
String name = dcEmployees.getName();//新增人员名称
dcShiftsRecord.setModifyContent("新增值班人员"+name);
dcShifts.setCreateTime(DateUtils.getNowDate());
dcShiftsRecord.setStation(station);//驻点
int shiftsRecord = dcShiftsMapper.insertDcShiftsRecord(dcShiftsRecord);
if (shiftsRecord==0){
msg="操作日志记录失败";
throw new ServiceException(msg);
}
} }
return 1; return 1;
} }

98
zc-business/src/main/resources/mapper/business/DcPerceivedEventsWarningMapper.xml

@ -46,29 +46,42 @@
order by warning.warning_time desc order by warning.warning_time desc
</select> </select>
<select id="selectSectionPerceivedEventsList" resultType="hashmap"> <select id="selectSectionPerceivedEventsList" resultType="hashmap">
select s.section_name sectionName,COUNT(1) number from dc_warning as w SELECT s.section_name AS sectionName, COALESCE(w_count.number, 0) AS number2
left JOIN dc_stake_mark as mark ON mark.stake_mark=w.stake_mark and mark.direction=w.direction FROM dc_road_section AS s
LEFT JOIN dc_road_section as s ON mark.section_id=s.id LEFT JOIN ( SELECT mark.section_id, COUNT(1) AS number FROM dc_warning AS w JOIN
where mark.stake_mark is not null and DATE_FORMAT(w.warning_time,'%Y-%m-%d')=DATE_FORMAT(#{warningTime},'%Y-%m-%d') dc_stake_mark AS mark ON mark.stake_mark = w.stake_mark AND mark.direction = w.direction
group by sectionName WHERE mark.stake_mark IS NOT NULL AND DATE_FORMAT(w.warning_time, '%Y-%m-%d') = DATE_FORMAT(#{warningTime}, '%Y-%m-%d')
HAVING number !=0 GROUP BY mark.section_id ) AS w_count ON s.id = w_count.section_id
order by number desc ORDER BY number DESC;
</select> </select>
<select id="selectSectionPerceivedNumber" resultType="java.util.HashMap"> <select id="selectSectionPerceivedNumber" resultType="java.util.HashMap">
select s.section_name sectionName, COUNT(1) number from dc_warning as w SELECT s.section_name AS sectionName, COALESCE(w_count.number, 0) AS number2
left JOIN dc_stake_mark as mark ON mark.stake_mark=w.stake_mark and mark.direction=w.direction FROM dc_road_section AS s
LEFT JOIN dc_road_section as s ON mark.section_id=s.id LEFT JOIN ( SELECT mark.section_id, COUNT(1) AS number FROM dc_warning AS w JOIN
where mark.stake_mark is not null and DATE_FORMAT(w.warning_time,'%Y-%m-%d')=DATE_FORMAT(#{warningTime},'%Y-%m-%d') dc_stake_mark AS mark ON mark.stake_mark = w.stake_mark AND mark.direction = w.direction
group by sectionName WHERE mark.stake_mark IS NOT NULL AND DATE_FORMAT(w.warning_time, '%Y-%m-%d') = DATE_FORMAT(#{warningTime}, '%Y-%m-%d')
HAVING number !=0 GROUP BY mark.section_id ) AS w_count ON s.id = w_count.section_id
</select> </select>
<select id="selectDailyCumulative" resultType="java.util.HashMap"> <select id="selectDailyCumulative" resultType="java.util.HashMap">
SELECT DATE_FORMAT(warning_time, '%Y-%m-%d %H') AS time, COUNT(*) AS number SELECT
FROM dc_warning DATE_FORMAT(CURDATE() + INTERVAL a.a HOUR, '%Y-%m-%d %H') AS time,
WHERE warning_time >= CURDATE() AND warning_time <![CDATA[<]]> CURDATE() + INTERVAL 1 DAY COALESCE(COUNT(dw.warning_time), 0) AS number
FROM (
SELECT 0 AS a
UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3
UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6
UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9
UNION ALL SELECT 10 UNION ALL SELECT 11 UNION ALL SELECT 12
UNION ALL SELECT 13 UNION ALL SELECT 14 UNION ALL SELECT 15
UNION ALL SELECT 16 UNION ALL SELECT 17 UNION ALL SELECT 18
UNION ALL SELECT 19 UNION ALL SELECT 20 UNION ALL SELECT 21
UNION ALL SELECT 22 UNION ALL SELECT 23
) AS a
LEFT JOIN dc_warning dw ON DATE_FORMAT(dw.warning_time, '%Y-%m-%d %H')
= DATE_FORMAT(CURDATE() + INTERVAL a.a HOUR, '%Y-%m-%d %H')
GROUP BY time GROUP BY time
ORDER BY time ORDER BY time;
</select> </select>
<select id="selectDailyCumulativeMonth" resultType="java.util.HashMap"> <select id="selectDailyCumulativeMonth" resultType="java.util.HashMap">
SELECT HOUR(warning_time) AS time, COUNT(*) AS number SELECT HOUR(warning_time) AS time, COUNT(*) AS number
@ -106,13 +119,22 @@
ORDER BY number DESC ORDER BY number DESC
</select> </select>
<select id="selectWarningTrendDay" resultType="java.util.HashMap"> <select id="selectWarningTrendDay" resultType="java.util.HashMap">
SELECT DATE_FORMAT(warning.warning_time, '%Y-%m-%d %H') AS time, COUNT(*) AS number select t1.n as time,IFNULL(t2.num,0)as number from
FROM dc_warning AS warning (SELECT 0 AS n UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL
LEFT JOIN dc_stake_mark AS mark ON warning.stake_mark=mark.stake_mark SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL
WHERE DATE_FORMAT(warning.warning_time,'%Y-%m-%d')=DATE_FORMAT(#{warningTime},'%Y-%m-%d') SELECT 8 UNION ALL SELECT 9 UNION ALL SELECT 10 UNION ALL SELECT 11 UNION ALL
AND warning.direction=#{direction} and mark.direction=#{direction} SELECT 12 UNION ALL SELECT 13 UNION ALL SELECT 14 UNION ALL SELECT 15 UNION ALL
AND mark.`section_id`=#{sectionId} SELECT 16 UNION ALL SELECT 17 UNION ALL SELECT 18 UNION ALL SELECT 19 UNION ALL
GROUP BY time SELECT 20 UNION ALL SELECT 21 UNION ALL SELECT 22 UNION ALL SELECT 23
) t1
left join
(select HOUR(warning_time) hours,count(*) num from dc_warning t1
left join dc_stake_mark t2 on t1.stake_mark = t2.stake_mark
and t1.direction = t2.direction where date_format(warning_time,'%Y-%m-%d') = date_format(#{warningTime},'%Y-%m-%d')
and t2.section_id = #{sectionId}
and t1.direction=#{direction} and t2.direction=#{direction}
GROUP BY hours) t2
on t1.n = t2.hours
</select> </select>
<select id="selectWarningTrendMonth" resultType="java.util.HashMap"> <select id="selectWarningTrendMonth" resultType="java.util.HashMap">
SELECT DATE(warning.warning_time) AS day, COUNT(*) AS number SELECT DATE(warning.warning_time) AS day, COUNT(*) AS number
@ -138,12 +160,17 @@
</select> </select>
<select id="selectWarningTrendYear" resultType="java.util.HashMap"> <select id="selectWarningTrendYear" resultType="java.util.HashMap">
SELECT month(warning.warning_time) AS month, COUNT(*) AS number select t1.n as month,IFNULL(t2.num,0)as number from
FROM dc_warning as warning (SELECT 0 AS n UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL
LEFT JOIN dc_stake_mark AS mark ON warning.stake_mark=mark.stake_mark SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL
where mark.`section_id`=#{sectionId} AND warning.direction=#{direction} and mark.direction=#{direction} SELECT 8 UNION ALL SELECT 9 UNION ALL SELECT 10 UNION ALL SELECT 11 UNION ALL
and DATE_FORMAT(warning.warning_time,'%Y')=DATE_FORMAT(#{warningTime},'%Y') SELECT 12
GROUP BY month ) t1 left join
(select month(warning_time) hours,count(*) num from dc_warning t1
left join dc_stake_mark t2 on t1.stake_mark = t2.stake_mark and t1.direction = t2.direction where
DATE_FORMAT(t1.warning_time,'%Y')=DATE_FORMAT(#{warningTime},'%Y') and t2.section_id =#{sectionId}
and t1.direction=#{direction} and t2.direction=#{direction} GROUP BY hours) t2
on t1.n = t2.hours
</select> </select>
<select id="selectWarningSectionTypeDayCount" resultType="java.lang.String"> <select id="selectWarningSectionTypeDayCount" resultType="java.lang.String">
SELECT COUNT(*) AS number FROM dc_warning as warning SELECT COUNT(*) AS number FROM dc_warning as warning
@ -287,12 +314,10 @@
</select> </select>
<select id="selectWarningMarkQuarterOptimize" resultType="java.util.HashMap"> <select id="selectWarningMarkQuarterOptimize" resultType="java.util.HashMap">
SELECT count( 1 ) sectionNumber,m.stake_mark stakeMarkId SELECT DISTINCT m.stake_mark AS stakeMarkId,COALESCE(wc.count, 0) AS sectionNumber
FROM dc_warning w FROM dc_stake_mark AS m LEFT JOIN ( SELECT stake_mark, COUNT(0) AS count FROM dc_warning WHERE
LEFT JOIN dc_stake_mark m ON w.stake_mark = m.stake_mark and m.direction=w.direction QUARTER(warning_time) =#{quarter} AND direction = #{direction} GROUP BY stake_mark ) AS wc
WHERE m.stake_mark IS NOT null and w.direction=#{direction} ON m.stake_mark = wc.stake_mark WHERE m.section_id = #{sectionId}
and QUARTER(w.warning_time)=#{quarter} and m.`section_id`=#{sectionId}
GROUP BY stakeMarkId
</select> </select>
<select id="selectWarningMarkDayOptimize" resultType="java.util.HashMap"> <select id="selectWarningMarkDayOptimize" resultType="java.util.HashMap">
SELECT DISTINCT m.stake_mark AS stakeMarkId,COALESCE(wc.count, 0) AS sectionNumber FROM SELECT DISTINCT m.stake_mark AS stakeMarkId,COALESCE(wc.count, 0) AS sectionNumber FROM
@ -303,7 +328,6 @@
<if test = 'type == "year"' > YEAR(warning_time) =DATE_FORMAT(#{warningTime},'%Y')</if> <if test = 'type == "year"' > YEAR(warning_time) =DATE_FORMAT(#{warningTime},'%Y')</if>
AND direction = #{direction} GROUP BY stake_mark ) AS wc ON m.stake_mark = wc.stake_mark AND direction = #{direction} GROUP BY stake_mark ) AS wc ON m.stake_mark = wc.stake_mark
WHERE m.section_id = #{sectionId} WHERE m.section_id = #{sectionId}
HAVING sectionNumber != 0;
</select> </select>
<!-- <select id="selectWarningMarkDayOptimize" resultType="java.util.HashMap">--> <!-- <select id="selectWarningMarkDayOptimize" resultType="java.util.HashMap">-->
<!-- SELECT DISTINCT m.stake_mark stakeMarkId,--> <!-- SELECT DISTINCT m.stake_mark stakeMarkId,-->

16
zc-business/src/main/resources/mapper/business/DcRoadSectionMapper.xml

@ -64,6 +64,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectRoadList" resultType="java.util.HashMap"> <select id="selectRoadList" resultType="java.util.HashMap">
select id,road_name roadName from dc_road select id,road_name roadName from dc_road
</select> </select>
<select id="selectMileage" resultType="java.util.HashMap">
select id ,CAST(SUBSTRING(SUBSTRING_INDEX(start_stake_mark,'+',1),2)AS UNSIGNED)*1000
+CAST(SUBSTRING_INDEX(start_stake_mark, '+', -1) AS UNSIGNED) startStakeMark,
CAST(SUBSTRING(SUBSTRING_INDEX(end_stake_mark,'+',1),2)AS UNSIGNED)*1000
+CAST(SUBSTRING_INDEX(end_stake_mark, '+', -1) AS UNSIGNED) endStakeMark
from dc_road_section
</select>
<select id="selectStakeMarkMileage" resultType="java.util.HashMap">
select stake_mark startStakeMark,
CAST(SUBSTRING(SUBSTRING_INDEX(stake_mark,'+',1),2)AS UNSIGNED)*1000
+CAST(SUBSTRING_INDEX(stake_mark, '+', -1) AS UNSIGNED) stakeMark from dc_stake_mark where stake_mark!='222'
</select>
<update id="updateStakeMarkRecord">
update dc_stake_mark set section_id=#{sectionId} where stake_mark=#{stakeMark}
</update>
<insert id="insertDcRoadSection" parameterType="DcRoadSection"> <insert id="insertDcRoadSection" parameterType="DcRoadSection">
insert into dc_road_section insert into dc_road_section

Loading…
Cancel
Save