Commit 4c147ab4 authored by 刘凡's avatar 刘凡

*)维保单位平均救援时间排名

parent 58831fa6
......@@ -8,6 +8,7 @@ import com.yeejoin.amos.boot.module.elevator.api.entity.DispatchTask;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* 派遣任务 Mapper 接口
......@@ -24,4 +25,6 @@ public interface DispatchTaskMapper extends BaseMapper<DispatchTask> {
List<WechatMyTaskListDto> getTaskListByPhonePager(@Param("phone") String phone, @Param("typeCode") String typeCode, @Param("current") Long current);
List<MainPersonDto> todayTaskPerson();
List<Map<String, Object>> rankUnitByRescueTime(@Param("regionCode") String regionCode);
}
......@@ -106,5 +106,26 @@
where to_days(t.dispatch_time) = TO_DAYS(now())
</select>
<select id="rankUnitByRescueTime" resultType="java.util.Map">
SELECT
tac.city,
tdt.sequence_nbr as sequenceNbr,
tdt.response_org_name as maintUnit,
AVG (TIMESTAMPDIFF (SECOND, tdt.arrive_time, tdt.save_time)) AS avgTime
FROM
tz_dispatch_task tdt
LEFT JOIN tz_alert_called tac ON tdt.alert_id = tac.sequence_nbr
LEFT JOIN tz_base_enterprise_info tbei ON tdt.response_org_id = tbei.sequence_nbr
WHERE
tac.alarm_type_code = '960'
AND tdt.org_type_code = 'repairUnit'
AND tac.biz_org_code LIKE concat(#{regionCode}, '%')
AND tdt.arrive_time IS NOT NULL
AND tdt.save_time IS NOT NULL
GROUP BY
tdt.response_org_id
ORDER BY
timeAvg
</select>
</mapper>
......@@ -122,7 +122,7 @@ public class DPStatisticsController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST", value = "大屏-应急-维保单位平均救援时间排名", notes = "大屏-应急-维保单位平均救援时间排名")
@PostMapping(value = "/yj/rankUnitByRescueTime")
public ResponseModel<List<AlertMaintenanceUnitStatisticsDto>> rankUnitByRescueTime(@Validated @RequestBody DPFilterParamDto dpFilterParamDto, BindingResult result) throws Exception {
public ResponseModel<List<Map<String, Object>>> rankUnitByRescueTime(@Validated @RequestBody DPFilterParamDto dpFilterParamDto, BindingResult result) throws Exception {
List<FieldError> fieldErrors = result.getFieldErrors();
if (!fieldErrors.isEmpty()) {
throw new BadRequest(fieldErrors.get(0).getDefaultMessage());
......
......@@ -32,6 +32,7 @@ import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
......@@ -57,6 +58,8 @@ public class DPStatisticsServiceImpl {
private AlertStatisticsMapper alertStatisticsMapper;
private DispatchTaskMapper dispatchTaskMapper;
@Autowired
AlertCalledServiceImpl alertCalledService;
......@@ -64,7 +67,7 @@ public class DPStatisticsServiceImpl {
private static Map<String, List<RegionModel>> regionChildRegionMap = new ConcurrentHashMap<>();
public DPStatisticsServiceImpl(YjBaseMapper yjBaseMapper, AlertCalledMapper alertCalledMapper, ElevatorMapper elevatorMapper, AlertRescueStatisticsMapper alertRescueStatisticsMapper, AlertUseUnitStatisticsMapper alertUseUnitStatisticsMapper, AlertMaintenanceUnitStatisticsMapper alertMaintenanceUnitStatisticsMapper, AlertStatisticsMapper alertStatisticsMapper) {
public DPStatisticsServiceImpl(YjBaseMapper yjBaseMapper, AlertCalledMapper alertCalledMapper, ElevatorMapper elevatorMapper, AlertRescueStatisticsMapper alertRescueStatisticsMapper, AlertUseUnitStatisticsMapper alertUseUnitStatisticsMapper, AlertMaintenanceUnitStatisticsMapper alertMaintenanceUnitStatisticsMapper, AlertStatisticsMapper alertStatisticsMapper, DispatchTaskMapper dispatchTaskMapper) {
this.yjBaseMapper = yjBaseMapper;
this.alertCalledMapper = alertCalledMapper;
this.elevatorMapper = elevatorMapper;
......@@ -72,6 +75,7 @@ public class DPStatisticsServiceImpl {
this.alertUseUnitStatisticsMapper = alertUseUnitStatisticsMapper;
this.alertMaintenanceUnitStatisticsMapper = alertMaintenanceUnitStatisticsMapper;
this.alertStatisticsMapper = alertStatisticsMapper;
this.dispatchTaskMapper = dispatchTaskMapper;
}
public JSONObject eventStatByDay(DPFilterParamDto dpFilterParamDto) throws Exception {
......@@ -199,16 +203,30 @@ public class DPStatisticsServiceImpl {
return Bean.toModels(alertUseUnitStatistics, AlertUseUnitStatisticsDto.class);
}
public List<AlertMaintenanceUnitStatisticsDto> rankUnitByRescueTime(DPFilterParamDto dpFilterParamDto) throws Exception {
String date = DateUtil.formatDate(new Date(), "yyyy-MM");
public List<Map<String, Object>> rankUnitByRescueTime(DPFilterParamDto dpFilterParamDto) throws Exception {
String orgCode = this.getAndSetOrgCode(dpFilterParamDto);
LambdaQueryWrapper<AlertMaintenanceUnitStatistics> lambda = new QueryWrapper<AlertMaintenanceUnitStatistics>().lambda();
lambda.likeLeft(AlertMaintenanceUnitStatistics::getSupervisoryUnitOrgCode, orgCode);
lambda.eq(AlertMaintenanceUnitStatistics :: getStatisticsDate, date);
List<AlertMaintenanceUnitStatistics> alertMaintenanceUnitStatistics = alertMaintenanceUnitStatisticsMapper.selectList(lambda);
List<AlertMaintenanceUnitStatisticsDto> models = Bean.toModels(alertMaintenanceUnitStatistics, AlertMaintenanceUnitStatisticsDto.class);
return models;
List<Map<String, Object>> maps = dispatchTaskMapper.rankUnitByRescueTime(orgCode);
maps.stream().forEach(x -> {
String avgTime = "";
Long seconds = Long.valueOf(x.get("avgTime").toString());
long days = TimeUnit.SECONDS.toDays(seconds);
long hours = TimeUnit.SECONDS.toHours(seconds) - TimeUnit.DAYS.toHours(days);
long minutes = TimeUnit.SECONDS.toMinutes(seconds) - TimeUnit.HOURS.toMinutes(hours);
if (!ValidationUtil.isEmpty(days) && days > 0){
avgTime = avgTime + days + "天";
}
if (!ValidationUtil.isEmpty(hours) && hours > 0){
avgTime = avgTime + hours + "小时";
}
if (!ValidationUtil.isEmpty(minutes) && minutes > 0){
avgTime = avgTime + minutes + "分钟";
}
if (seconds < 60){
avgTime = avgTime + seconds + "秒";
}
x.put("avgTime", avgTime);
});
return maps;
}
public JSONObject regionEventRank(DPFilterParamDto dpFilterParamDto) throws Exception {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment