巡检首页接口

This commit is contained in:
2265829957@qq.com 2026-02-25 20:39:16 +08:00
parent 69bb678a58
commit 3b6a5efcd8
5 changed files with 150 additions and 25 deletions

View File

@ -31,33 +31,26 @@ public class XhpcInspectionController extends BaseController {
@GetMapping("/getDataBoard") @GetMapping("/getDataBoard")
public AjaxResult getDataBoard(){ public AjaxResult getDataBoard(){
Map<String,Object> map1 =new HashMap<>(); return AjaxResult.success(xhpcInspectionService.getDataBoard());
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);
} }
@GetMapping("/getRealTimeWarning") @GetMapping("/getRealTimeWarning")
public AjaxResult getRealTimeWarning(){ public AjaxResult getRealTimeWarning(){
List<Map<String,Object>> mapList =new ArrayList<>(); List<Map<String,Object>> mapList =new ArrayList<>();
Map<String,Object> map1 =new HashMap<>(); // Map<String,Object> map1 =new HashMap<>();
map1.put("stationName","小华充电团结平安村充电站"); // map1.put("stationName","小华充电团结平安村充电站");
map1.put("terminalName","4号桩B枪"); // map1.put("terminalName","4号桩B枪");
map1.put("time","2026-2-5 08:35:45"); // map1.put("time","2026-2-5 08:35:45");
map1.put("conent","离线时间超过2小时"); // map1.put("conent","离线时间超过2小时");
mapList.add(map1); // mapList.add(map1);
//
Map<String,Object> map2 =new HashMap<>(); // Map<String,Object> map2 =new HashMap<>();
map2.put("stationName","小华充电团结平安村充电站"); // map2.put("stationName","小华充电团结平安村充电站");
map2.put("terminalName","3号桩B枪"); // map2.put("terminalName","3号桩B枪");
map2.put("time","2026-2-4 08:35:45"); // map2.put("time","2026-2-4 08:35:45");
map2.put("conent","离线时间超过1小时"); // map2.put("conent","离线时间超过1小时");
mapList.add(map2); // mapList.add(map2);
return AjaxResult.success(mapList); return AjaxResult.success(mapList);
@ -83,7 +76,7 @@ public class XhpcInspectionController extends BaseController {
} }
@GetMapping("/timing") @GetMapping("/timing")
@Scheduled(cron = "0 50 23 * * ? ") @Scheduled(cron = "0 50 0 * * ? ")
public void timing(){ public void timing(){
// 系统自动生成每日巡检项2350 // 系统自动生成每日巡检项2350
xhpcInspectionService.timing(); xhpcInspectionService.timing();

View File

@ -3,6 +3,7 @@ package com.xhpc.order.mapper;
import com.xhpc.order.domain.XhpcInspection; import com.xhpc.order.domain.XhpcInspection;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -25,4 +26,18 @@ public interface XhpcInspectionMapper {
List<Map<String, Object>> getWXXhpcTerminalMassage(@Param("chargingStationId") Long chargingStationId); List<Map<String, Object>> getWXXhpcTerminalMassage(@Param("chargingStationId") Long chargingStationId);
List<Map<String, Object>> getInspectionUserList(@Param("userId") Long userId); 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);
} }

View File

@ -20,4 +20,6 @@ public interface IXhpcInspectionService {
List<Map<String, Object>> getStationList(HttpServletRequest request); List<Map<String, Object>> getStationList(HttpServletRequest request);
List<Map<String, Object>> getInspectionUserList(HttpServletRequest request); List<Map<String, Object>> getInspectionUserList(HttpServletRequest request);
Map<String,Object> getDataBoard();
} }

View File

@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.*; import java.util.*;
@Service @Service
@ -31,7 +32,15 @@ public class XhpcInspectionServiceImpl implements IXhpcInspectionService {
@Override @Override
public List<Map<String, Object>> getInspectionList(Long stationId, String time) { public List<Map<String, Object>> getInspectionList(Long stationId, String time) {
String today = DateUtil.today(); String today = DateUtil.today();
return xhpcInspectionMapper.getInspectionList(stationId, today);
if(time==null || "".equals(time)){
return xhpcInspectionMapper.getInspectionList(stationId, today);
}
return xhpcInspectionMapper.getInspectionList(stationId, time);
} }
@Override @Override
@ -244,4 +253,63 @@ public class XhpcInspectionServiceImpl implements IXhpcInspectionService {
List<Map<String, Object>> inspectionUserList = xhpcInspectionMapper.getInspectionUserList(logUserId); List<Map<String, Object>> inspectionUserList = xhpcInspectionMapper.getInspectionUserList(logUserId);
return inspectionUserList; 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;
}
} }

View File

@ -217,7 +217,6 @@
where inspection_id=#{inspectionId} where inspection_id=#{inspectionId}
</update> </update>
<select id="getChargingStationEmptyOrder" resultType="map"> <select id="getChargingStationEmptyOrder" resultType="map">
SELECT SELECT
@ -351,7 +350,8 @@
select select
t.charging_station_id as chargingStationId, 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, xct.name as chargingStationName,
su.nick_name as nickName, 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, (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>
<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> </mapper>