巡检首页接口
This commit is contained in:
parent
69bb678a58
commit
3b6a5efcd8
@ -31,33 +31,26 @@ public class XhpcInspectionController extends BaseController {
|
||||
|
||||
@GetMapping("/getDataBoard")
|
||||
public AjaxResult getDataBoard(){
|
||||
Map<String,Object> map1 =new HashMap<>();
|
||||
map1.put("stationSum",11);
|
||||
map1.put("abnormalStation",1);
|
||||
map1.put("todayOrder",236);
|
||||
map1.put("emptyOrderRate","23.56");
|
||||
map1.put("completionRate","75%");
|
||||
map1.put("onlineRate","93.5%");
|
||||
return AjaxResult.success(map1);
|
||||
return AjaxResult.success(xhpcInspectionService.getDataBoard());
|
||||
}
|
||||
|
||||
@GetMapping("/getRealTimeWarning")
|
||||
public AjaxResult getRealTimeWarning(){
|
||||
List<Map<String,Object>> mapList =new ArrayList<>();
|
||||
|
||||
Map<String,Object> map1 =new HashMap<>();
|
||||
map1.put("stationName","小华充电团结平安村充电站");
|
||||
map1.put("terminalName","4号桩B枪");
|
||||
map1.put("time","2026-2-5 08:35:45");
|
||||
map1.put("conent","离线时间超过2小时");
|
||||
mapList.add(map1);
|
||||
|
||||
Map<String,Object> map2 =new HashMap<>();
|
||||
map2.put("stationName","小华充电团结平安村充电站");
|
||||
map2.put("terminalName","3号桩B枪");
|
||||
map2.put("time","2026-2-4 08:35:45");
|
||||
map2.put("conent","离线时间超过1小时");
|
||||
mapList.add(map2);
|
||||
// Map<String,Object> map1 =new HashMap<>();
|
||||
// map1.put("stationName","小华充电团结平安村充电站");
|
||||
// map1.put("terminalName","4号桩B枪");
|
||||
// map1.put("time","2026-2-5 08:35:45");
|
||||
// map1.put("conent","离线时间超过2小时");
|
||||
// mapList.add(map1);
|
||||
//
|
||||
// Map<String,Object> map2 =new HashMap<>();
|
||||
// map2.put("stationName","小华充电团结平安村充电站");
|
||||
// map2.put("terminalName","3号桩B枪");
|
||||
// map2.put("time","2026-2-4 08:35:45");
|
||||
// map2.put("conent","离线时间超过1小时");
|
||||
// mapList.add(map2);
|
||||
|
||||
|
||||
return AjaxResult.success(mapList);
|
||||
@ -83,7 +76,7 @@ public class XhpcInspectionController extends BaseController {
|
||||
}
|
||||
|
||||
@GetMapping("/timing")
|
||||
@Scheduled(cron = "0 50 23 * * ? ")
|
||||
@Scheduled(cron = "0 50 0 * * ? ")
|
||||
public void timing(){
|
||||
// 系统自动生成每日巡检项23:50
|
||||
xhpcInspectionService.timing();
|
||||
|
||||
@ -3,6 +3,7 @@ package com.xhpc.order.mapper;
|
||||
import com.xhpc.order.domain.XhpcInspection;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -25,4 +26,18 @@ public interface XhpcInspectionMapper {
|
||||
List<Map<String, Object>> getWXXhpcTerminalMassage(@Param("chargingStationId") Long chargingStationId);
|
||||
|
||||
List<Map<String, Object>> getInspectionUserList(@Param("userId") Long userId);
|
||||
|
||||
int stationSum();
|
||||
|
||||
int abnormalStation(@Param("time") String time);
|
||||
|
||||
int todayOrder(@Param("time") String time);
|
||||
|
||||
int emptyOrderRate(@Param("time") String time);
|
||||
|
||||
String completionRate(@Param("time") String time);
|
||||
|
||||
List<Map<String, Object>> getChargingStationList();
|
||||
|
||||
BigDecimal onlineRate(int normal);
|
||||
}
|
||||
|
||||
@ -20,4 +20,6 @@ public interface IXhpcInspectionService {
|
||||
List<Map<String, Object>> getStationList(HttpServletRequest request);
|
||||
|
||||
List<Map<String, Object>> getInspectionUserList(HttpServletRequest request);
|
||||
|
||||
Map<String,Object> getDataBoard();
|
||||
}
|
||||
|
||||
@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
@ -31,9 +32,17 @@ public class XhpcInspectionServiceImpl implements IXhpcInspectionService {
|
||||
@Override
|
||||
public List<Map<String, Object>> getInspectionList(Long stationId, String time) {
|
||||
String today = DateUtil.today();
|
||||
|
||||
if(time==null || "".equals(time)){
|
||||
return xhpcInspectionMapper.getInspectionList(stationId, today);
|
||||
}
|
||||
|
||||
return xhpcInspectionMapper.getInspectionList(stationId, time);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void timing() {
|
||||
|
||||
@ -244,4 +253,63 @@ public class XhpcInspectionServiceImpl implements IXhpcInspectionService {
|
||||
List<Map<String, Object>> inspectionUserList = xhpcInspectionMapper.getInspectionUserList(logUserId);
|
||||
return inspectionUserList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getDataBoard() {
|
||||
Map<String, Object> map1 = new HashMap<>();
|
||||
//场站总数量
|
||||
int stationSum = xhpcInspectionMapper.stationSum();
|
||||
map1.put("stationSum",stationSum);
|
||||
String today = DateUtil.today();
|
||||
int abnormalStation = xhpcInspectionMapper.abnormalStation(today);
|
||||
map1.put("abnormalStation",abnormalStation);
|
||||
|
||||
|
||||
int todayOrder = xhpcInspectionMapper.todayOrder(today);
|
||||
map1.put("todayOrder",todayOrder);
|
||||
|
||||
int emptyOrderRate = xhpcInspectionMapper.emptyOrderRate(today);
|
||||
double result = (double) todayOrder / emptyOrderRate;
|
||||
String formatted = String.format("%.2f", result);
|
||||
map1.put("emptyOrderRate",formatted);
|
||||
|
||||
|
||||
String completionRate = xhpcInspectionMapper.completionRate(today);
|
||||
map1.put("completionRate",completionRate);
|
||||
|
||||
List<Map<String, Object>> mapList = xhpcInspectionMapper.getChargingStationList();
|
||||
int normal=0;
|
||||
for (int j = 0; j < mapList.size(); j++) {
|
||||
Map<String, Object> objectMap = mapList.get(j);
|
||||
Long stationId = Long.valueOf(objectMap.get("stationId").toString());
|
||||
List<Map<String, Object>> list = xhpcInspectionMapper.getWXXhpcTerminalMassage(stationId);
|
||||
if (list != null && list.size() > 0) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Map<String, Object> map = list.get(i);
|
||||
//终端状态用 redis数据
|
||||
if(map.get("serialNumber") !=null){
|
||||
Map<String, Object> cacheMap =redisService.getCacheMap("gun:"+map.get("serialNumber").toString());
|
||||
if(!cacheMap.isEmpty()){
|
||||
if ("离线".equals(cacheMap.get("status").toString())){
|
||||
}else if("故障".equals(cacheMap.get("status").toString())){
|
||||
}else if("空闲".equals(cacheMap.get("status").toString())){
|
||||
normal++;
|
||||
}else{
|
||||
normal++;
|
||||
}
|
||||
}else{
|
||||
|
||||
}
|
||||
}else{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BigDecimal bigDecimal = xhpcInspectionMapper.onlineRate(normal);
|
||||
map1.put("onlineRate",bigDecimal+"%");
|
||||
|
||||
|
||||
return map1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -217,7 +217,6 @@
|
||||
where inspection_id=#{inspectionId}
|
||||
</update>
|
||||
|
||||
|
||||
<select id="getChargingStationEmptyOrder" resultType="map">
|
||||
|
||||
SELECT
|
||||
@ -351,7 +350,8 @@
|
||||
|
||||
select
|
||||
t.charging_station_id as chargingStationId,
|
||||
t.data_time as dataTime,
|
||||
t.data_time as dataTimeY,
|
||||
DATE_FORMAT(t.data_time, '%Y年%m月%d日') AS dataTime,
|
||||
xct.name as chargingStationName,
|
||||
su.nick_name as nickName,
|
||||
(select count(inspection_id) from xhpc_inspection where charging_station_id=t.charging_station_id and data_time=t.data_time) as totalItem,
|
||||
@ -366,6 +366,53 @@
|
||||
|
||||
</select>
|
||||
|
||||
<select id="stationSum" resultType="int">
|
||||
select count(*) from xhpc_charging_station where del_flag =0
|
||||
</select>
|
||||
|
||||
<select id="abnormalStation" resultType="int">
|
||||
select count(inspection_id) from xhpc_inspection where data_time=#{time} and status=2
|
||||
group by charging_station_id,data_time
|
||||
</select>
|
||||
|
||||
<select id="todayOrder" resultType="int">
|
||||
select count(*) from xhpc_history_order where DATE_FORMAT(end_time, '%Y-%m-%d') = #{time}
|
||||
</select>
|
||||
|
||||
<select id="emptyOrderRate" resultType="int">
|
||||
select count(*) from xhpc_history_order where DATE_FORMAT(end_time, '%Y-%m-%d') = #{time}
|
||||
and (xh.total_price=0
|
||||
or xh.stop_reason_evcs ='40'
|
||||
or xh.stop_reason_evcs ='41'
|
||||
or xh.stop_reason_evcs ='6E'
|
||||
or xh.stop_reason_evcs ='4E'
|
||||
or xh.stop_reason_evcs ='199')
|
||||
</select>
|
||||
|
||||
|
||||
<select id="completionRate" resultType="string">
|
||||
SELECT
|
||||
CONCAT(
|
||||
ROUND(
|
||||
(SUM(CASE WHEN status != 0 THEN 1 ELSE 0 END) * 100.0) / COUNT(*),2),'%' ) as completion_rate
|
||||
FROM xhpc_inspection
|
||||
WHERE data_time = #{time};
|
||||
</select>
|
||||
|
||||
<select id="getChargingStationList" resultType="map">
|
||||
select charging_station_id as stationId from xhpc_charging_station where del_flag =0
|
||||
</select>
|
||||
|
||||
<select id="onlineRate" resultType="java.math.BigDecimal">
|
||||
SELECT
|
||||
CASE
|
||||
WHEN COUNT(*) = 0 THEN 0
|
||||
ELSE ROUND(
|
||||
(CAST(#{normal} AS DECIMAL(10,2)) / COUNT(*)) * 100,
|
||||
2
|
||||
)
|
||||
END as inspection_rate
|
||||
FROM xhpc_terminal
|
||||
WHERE del_flag = 0
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user