diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcInspectionController.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcInspectionController.java index 383b9d67..ed720520 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcInspectionController.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcInspectionController.java @@ -31,33 +31,26 @@ public class XhpcInspectionController extends BaseController { @GetMapping("/getDataBoard") public AjaxResult getDataBoard(){ - Map 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> mapList =new ArrayList<>(); - Map 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 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 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 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(); diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcInspectionMapper.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcInspectionMapper.java index a7011570..dd28b4b8 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcInspectionMapper.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcInspectionMapper.java @@ -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> getWXXhpcTerminalMassage(@Param("chargingStationId") Long chargingStationId); List> 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> getChargingStationList(); + + BigDecimal onlineRate(int normal); } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcInspectionService.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcInspectionService.java index 94f2c974..fea40c87 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcInspectionService.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcInspectionService.java @@ -20,4 +20,6 @@ public interface IXhpcInspectionService { List> getStationList(HttpServletRequest request); List> getInspectionUserList(HttpServletRequest request); + + Map getDataBoard(); } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcInspectionServiceImpl.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcInspectionServiceImpl.java index 637d43f3..29caf352 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcInspectionServiceImpl.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcInspectionServiceImpl.java @@ -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,7 +32,15 @@ public class XhpcInspectionServiceImpl implements IXhpcInspectionService { @Override public List> getInspectionList(Long stationId, String time) { 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 @@ -244,4 +253,63 @@ public class XhpcInspectionServiceImpl implements IXhpcInspectionService { List> inspectionUserList = xhpcInspectionMapper.getInspectionUserList(logUserId); return inspectionUserList; } + + @Override + public Map getDataBoard() { + Map 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> mapList = xhpcInspectionMapper.getChargingStationList(); + int normal=0; + for (int j = 0; j < mapList.size(); j++) { + Map objectMap = mapList.get(j); + Long stationId = Long.valueOf(objectMap.get("stationId").toString()); + List> list = xhpcInspectionMapper.getWXXhpcTerminalMassage(stationId); + if (list != null && list.size() > 0) { + for (int i = 0; i < list.size(); i++) { + Map map = list.get(i); + //终端状态用 redis数据 + if(map.get("serialNumber") !=null){ + Map 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; + } } diff --git a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcInspectionMapper.xml b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcInspectionMapper.xml index 42d5345d..edb9dd1d 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcInspectionMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcInspectionMapper.xml @@ -217,7 +217,6 @@ where inspection_id=#{inspectionId} - + + + + + + + + + + + +