From 0667f26b163dc391cad2f6c8856f078481e6103b Mon Sep 17 00:00:00 2001 From: "2265829957@qq.com" <2265829957@qq.com> Date: Mon, 23 Feb 2026 17:16:25 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=90=E7=BB=B4=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/XhpcInspectionController.java | 27 +--- .../order/mapper/XhpcInspectionMapper.java | 6 + .../order/service/IXhpcInspectionService.java | 4 + .../impl/XhpcInspectionServiceImpl.java | 146 ++++++++++++++++-- .../resources/mapper/XhpcInspectionMapper.xml | 133 +++++++++++++++- 5 files changed, 277 insertions(+), 39 deletions(-) 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 7a6f7fee..3106adb8 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 @@ -67,33 +67,10 @@ public class XhpcInspectionController extends BaseController { @GetMapping("/getStationList") - public AjaxResult getStationList() { + public AjaxResult getStationList(HttpServletRequest request) { //stationName:场站名称 twoDayOrder:订单量 emptyOrderRate:空订单率 // normal:正常 offline:离线 fault:故障 "未知": 3 - List> mapList = new ArrayList<>(); - - Map map1 = new HashMap<>(); - map1.put("stationName", "小华充电团结平安村充电站"); - map1.put("stationId",1); - map1.put("twoDayOrder", "243"); - map1.put("emptyOrderRate", "34.8%"); - map1.put("normal", 7); - map1.put("offline", 1); - map1.put("fault", 2); - map1.put("unknown", 3); - mapList.add(map1); - - Map map2 = new HashMap<>(); - map2.put("stationName", "小华充电高堆路充电站"); - map2.put("stationId",2); - map2.put("twoDayOrder", "2430"); - map2.put("emptyOrderRate", "34.8%"); - map2.put("normal", 15); - map2.put("offline", 1); - map2.put("fault", 2); - map2.put("unknown", 3); - mapList.add(map2); - return AjaxResult.success(mapList); + return AjaxResult.success(xhpcInspectionService.getStationList(request)); } 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 8ce85b3a..850d80d8 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 @@ -18,5 +18,11 @@ public interface XhpcInspectionMapper { int updateInspection(XhpcInspection xhpcInspection); + List> getChargingStationEmptyOrder(@Param("status") Integer status,@Param("logOperatorId")Long logOperatorId,@Param("tenantId")String tenantId,@Param("beginOfDay")String beginOfDay,@Param("endOfDay")String endOfDay); + + List> getTerminalEmptyOrder(@Param("chargingStationId")Long chargingStationId,@Param("status") Integer status,@Param("logOperatorId")Long logOperatorId,@Param("tenantId")String tenantId,@Param("beginOfDay")String beginOfDay,@Param("endOfDay")String endOfDay); + + List> getWXXhpcTerminalMassage(@Param("chargingStationId") Long chargingStationId); + } 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 899641af..2697ff4f 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 @@ -16,4 +16,8 @@ public interface IXhpcInspectionService { AjaxResult getInspectionById(Long stationId, String id); AjaxResult addInspection(HttpServletRequest request, XhpcInspection xhpcInspection); + + List> getStationList(HttpServletRequest request); + + } 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 bea5d6ac..32c1827b 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 @@ -1,18 +1,21 @@ package com.xhpc.order.service.impl; +import cn.hutool.core.date.DateUtil; +import com.xhpc.common.core.utils.SecurityUtils; import com.xhpc.common.core.web.domain.AjaxResult; +import com.xhpc.common.redis.service.RedisService; import com.xhpc.common.security.service.TokenService; +import com.xhpc.common.util.UserTypeUtil; import com.xhpc.order.domain.XhpcInspection; import com.xhpc.order.mapper.XhpcInspectionMapper; import com.xhpc.order.service.IXhpcInspectionService; +import com.xhpc.system.api.domain.SysUser; import com.xhpc.system.api.model.LoginUser; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.servlet.http.HttpServletRequest; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; @Service public class XhpcInspectionServiceImpl implements IXhpcInspectionService { @@ -21,7 +24,8 @@ public class XhpcInspectionServiceImpl implements IXhpcInspectionService { private XhpcInspectionMapper xhpcInspectionMapper; @Autowired private TokenService tokenService; - + @Autowired + private RedisService redisService; @Override @@ -37,42 +41,60 @@ public class XhpcInspectionServiceImpl implements IXhpcInspectionService { for (int i = 0; i map = mapList.get(i); - Long chargingStationId = Long.getLong(map.get("chargingStationId").toString()); + String today = DateUtil.today(); + Long chargingStationId = Long.valueOf(map.get("chargingStationId").toString()); + Long terminalId = Long.valueOf(map.get("terminalId").toString()); if(i==0){ XhpcInspection xhpcInspection = new XhpcInspection(); xhpcInspection.setName("箱变"); xhpcInspection.setChargingStationId(chargingStationId); + xhpcInspection.setTerminalId(terminalId); xhpcInspection.setStatus(0); xhpcInspection.setType(1); + xhpcInspection.setDataIime(today); + xhpcInspection.setCreateTime(new Date()); xhpcInspectionMapper.installInspection(xhpcInspection); XhpcInspection xhpcInspection1 = new XhpcInspection(); xhpcInspection1.setName("监控"); - xhpcInspection.setChargingStationId(chargingStationId); + xhpcInspection1.setTerminalId(terminalId); + xhpcInspection1.setChargingStationId(chargingStationId); xhpcInspection1.setStatus(0); xhpcInspection1.setType(2); + xhpcInspection1.setDataIime(today); + xhpcInspection1.setCreateTime(new Date()); xhpcInspectionMapper.installInspection(xhpcInspection1); XhpcInspection xhpcInspection2 = new XhpcInspection(); xhpcInspection2.setName("道闸"); - xhpcInspection.setChargingStationId(chargingStationId); + xhpcInspection2.setTerminalId(terminalId); + xhpcInspection2.setChargingStationId(chargingStationId); xhpcInspection2.setStatus(0); xhpcInspection2.setType(3); + xhpcInspection2.setDataIime(today); + xhpcInspection2.setCreateTime(new Date()); xhpcInspectionMapper.installInspection(xhpcInspection2); XhpcInspection xhpcInspection3 = new XhpcInspection(); xhpcInspection3.setName("远程连接"); - xhpcInspection.setChargingStationId(chargingStationId); + xhpcInspection3.setTerminalId(terminalId); + xhpcInspection3.setChargingStationId(chargingStationId); xhpcInspection3.setStatus(0); xhpcInspection3.setType(4); + xhpcInspection3.setDataIime(today); + xhpcInspection3.setCreateTime(new Date()); xhpcInspectionMapper.installInspection(xhpcInspection3); } XhpcInspection xhpcInspection = new XhpcInspection(); xhpcInspection.setName(map.get("name").toString()); xhpcInspection.setChargingStationId(chargingStationId); - int status = Integer.getInteger(map.get("status").toString()); - if(status==0){ + xhpcInspection.setTerminalId(terminalId); + xhpcInspection.setCreateTime(new Date()); + String statusY = map.get("status").toString(); + //System.out.println("statusY="+statusY); + //int status = Math.toIntExact(Long.getLong(map.get("status").toString())); + if("0".equals(statusY)){ xhpcInspection.setStatus(0); }else{ xhpcInspection.setStatus(3); @@ -81,7 +103,7 @@ public class XhpcInspectionServiceImpl implements IXhpcInspectionService { } } xhpcInspection.setType(0); - + xhpcInspection.setDataIime(today); xhpcInspectionMapper.installInspection(xhpcInspection); } } @@ -116,4 +138,106 @@ public class XhpcInspectionServiceImpl implements IXhpcInspectionService { xhpcInspectionMapper.updateInspection(xhpcInspection); return AjaxResult.success(); } + + @Override + public List> getStationList(HttpServletRequest request) { + + + Date startTime1 = DateUtil.beginOfDay(new Date()); + String startTime = DateUtil.format(startTime1,"yyyy-MM-dd HH:mm:ss"); + //一天的结束,结果:2017-03-01 23:59:59 + Date endTime1 = DateUtil.endOfDay(new Date()); + String endTime = DateUtil.format(endTime1,"yyyy-MM-dd HH:mm:ss"); + Long chargingStationId =null; + //判断登录用户是系统用户还是运维人员 + LoginUser loginUser = tokenService.getLoginUser(request); + + String tenantId = loginUser.getTenantId(); + Long logUserId = SecurityUtils.getUserId(); + SysUser sysUser = loginUser.getSysUser(); + List> mapList =new ArrayList<>(); + if(tenantId !=null && !"".equals(tenantId)){ + if(UserTypeUtil.SYS_USER_TYPE_FOUR.equals(sysUser.getUserType())){ + if(chargingStationId==null){ + //运维管理人员 + mapList= xhpcInspectionMapper.getChargingStationEmptyOrder(3,logUserId,tenantId,startTime,endTime); + }else { + //运营商看自己的场站 + mapList= xhpcInspectionMapper.getTerminalEmptyOrder(chargingStationId,3,logUserId,tenantId,startTime,endTime); + } + }else{ + if(chargingStationId==null){ + if(sysUser.getUserId() !=UserTypeUtil.USER_ID){ + Long logOperatorId = sysUser.getOperatorId(); + if ("01".equals(sysUser.getUserType())) { + //运营商看自己的场站 + mapList= xhpcInspectionMapper.getChargingStationEmptyOrder(1,logOperatorId,tenantId,startTime,endTime); + }else{ + //查询赋值的场站 + mapList= xhpcInspectionMapper.getChargingStationEmptyOrder(2,logUserId,tenantId,startTime,endTime); + } + }else{ + //全部桩 + mapList= xhpcInspectionMapper.getChargingStationEmptyOrder(0,null,tenantId,startTime,endTime); + } + }else{ + //单个场站空订单率 + if(sysUser.getUserId() !=UserTypeUtil.USER_ID){ + Long logOperatorId = sysUser.getOperatorId(); + if ("01".equals(sysUser.getUserType())) { + //运营商看自己的场站 + mapList= xhpcInspectionMapper.getTerminalEmptyOrder(chargingStationId,1,logOperatorId,tenantId,startTime,endTime); + }else{ + //查询赋值的场站 + mapList= xhpcInspectionMapper.getTerminalEmptyOrder(chargingStationId,2,logUserId,tenantId,startTime,endTime); + } + }else{ + //全部桩 + mapList= xhpcInspectionMapper.getTerminalEmptyOrder(chargingStationId,0,null,tenantId,startTime,endTime); + } + } + + } + } + + //桩的状态 + 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); + int normal=0; + int offline=0; + int fault=0; + int unknown=0; + 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())){ + offline++; + }else if("故障".equals(cacheMap.get("status").toString())){ + fault++; + }else if("空闲".equals(cacheMap.get("status").toString())){ + normal++; + }else{ + normal++; + } + }else{ + unknown++; + } + }else{ + unknown++; + } + } + } + objectMap.put("normal", normal); + objectMap.put("offline", offline); + objectMap.put("fault", fault); + objectMap.put("unknown", unknown); + } + return mapList; + } } 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 353f1c9b..ef11162c 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcInspectionMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcInspectionMapper.xml @@ -46,7 +46,8 @@ @@ -218,10 +219,136 @@ maintenance_record=#{maintenanceRecord} user_id=#{userId} - where inspection_id=#{inspectionId} + + + + +