From d1639320f6f40df62e2c7f4009f40d51b5bf051e Mon Sep 17 00:00:00 2001 From: yuyang <2265829957@qq.com> Date: Wed, 11 Aug 2021 16:25:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A1=A9=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/XhpcChargingStationMapper.xml | 2 +- .../controller/HxpcChargeOrderController.java | 1 + .../order/controller/WebSocketController.java | 37 ++++++ .../XhpcHistoryOrderController.java | 6 +- .../XhpcRealTimeOrderController.java | 33 ++++- .../order/mapper/HxpcChargeOrderMapper.java | 2 +- .../order/mapper/XhpcHistoryOrderMapper.java | 2 +- .../order/mapper/XhpcRealTimeOrderMapper.java | 37 ++++++ .../service/IXhpcHistoryOrderService.java | 2 +- .../service/IXhpcRealTimeOrderService.java | 24 +++- .../impl/HxpcChargeOrderServiceImpl.java | 7 +- .../impl/XhpcHistoryOrderServiceImpl.java | 5 +- .../impl/XhpcRealTimeOrderServiceImpl.java | 22 ++++ .../mapper/XhpcChargeOrderMapper.xml | 46 ++++--- .../mapper/XhpcHistoryOrderMapper.xml | 9 +- .../mapper/XhpcRealTimeOrderMapper.xml | 116 ++++++++++++++---- 16 files changed, 295 insertions(+), 56 deletions(-) diff --git a/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingStationMapper.xml b/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingStationMapper.xml index 37c4b9a8..9681bd28 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingStationMapper.xml +++ b/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingStationMapper.xml @@ -341,7 +341,7 @@ select te.name as name, cp.power as power, cp.auxiliary_power_supply as auxiliaryPowerSupply, - cp.serial_number as serialNumber, + te.serial_number as serialNumber, cp.input_voltage as inputVoltage from xhpc_terminal as te left join xhpc_charging_pile as cp on cp.charging_pile_id = te.charging_pile_id diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/HxpcChargeOrderController.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/HxpcChargeOrderController.java index 00803794..bb0dbf99 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/HxpcChargeOrderController.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/HxpcChargeOrderController.java @@ -73,4 +73,5 @@ public class HxpcChargeOrderController extends BaseController { return iHxpcChargeOrderService.stopUp(userId, serialNumber,chargingOrderId); } + } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/WebSocketController.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/WebSocketController.java index 18c95314..ab1e0736 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/WebSocketController.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/WebSocketController.java @@ -50,9 +50,45 @@ public class WebSocketController { public void onOpen(@PathParam("userId") Long userId,Session session){ this.userId =userId; this.session = session; + System.out.println("userId:"+userId); + System.out.println("session:"+session); webSocketSet.add(this); //加入set中 addOnlineCount(); //在线数加1 System.out.println("有新连接加入!当前在线人数为" + getOnlineCount()); + try { + this.session.getBasicRemote().sendText("推送消息"); + } catch (IOException e) { + e.printStackTrace(); + } + } + /** + * 给指定的人发送消息 + * @param message + */ + @OnMessage + public void sendToUser(String message) { + String sendUserno = message.split("[|]")[1]; + String sendMessage = message.split("[|]")[0]; + try { + if (webSocketSet.get(sendUserno) != null) { + webSocketSet.get(sendUserno).sendMessage("用户" + userno + "发来消息:" + "
" + sendMessage); + } else { + System.out.println("当前用户不在线"); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + /** + * 获取当前时间 + * + * @return + */ + private String getNowTime() { + Date date = new Date(); + DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String time = format.format(date); + return time; } /** @@ -93,6 +129,7 @@ public class WebSocketController { " \"remainingTime\": \"45\"\n" + " }\n" + "}"; + //终端编号、订单信息需要获取 ApplicationContext act = ApplicationContextRegister.getApplicationContext(); RedisService redisService = act.getBean(RedisService.class); Object cacheObject = redisService.getCacheObject("gun:1472583698524602.seqdec"); diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcHistoryOrderController.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcHistoryOrderController.java index c0363224..15a810ed 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcHistoryOrderController.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcHistoryOrderController.java @@ -43,12 +43,14 @@ public class XhpcHistoryOrderController extends BaseController { * 用户订单详情接口 * @param userId 用户id * @param historyOrderId 历史订单id + * @param type 1 历史订单id 2 充电订单id (暂时没用) + * @param chargingOrderId 充电订单id * @return */ @GetMapping("/gethistotyOrderMessage") - public AjaxResult gethistotyOrderMessage(@RequestParam Long userId,@RequestParam Long historyOrderId) + public AjaxResult gethistotyOrderMessage(@RequestParam Long userId,@RequestParam Long historyOrderId,Integer type,Long chargingOrderId) { - return xhpcHistoryOrderService.gethistotyOrderMessage(userId,historyOrderId); + return xhpcHistoryOrderService.gethistotyOrderMessage(userId,historyOrderId,type,chargingOrderId); } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcRealTimeOrderController.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcRealTimeOrderController.java index 2b658c7c..656adcd0 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcRealTimeOrderController.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcRealTimeOrderController.java @@ -8,6 +8,7 @@ import io.swagger.annotations.Api; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -48,10 +49,36 @@ public class XhpcRealTimeOrderController extends BaseController { /** * 实时订单详情 */ - @GetMapping("/message") - public AjaxResult message(@RequestParam Long realTimeOrderId) + @GetMapping("/getMessage") + public AjaxResult getMessage(@RequestParam Long realTimeOrderId) { - return null; + return AjaxResult.success(xhpcRealTimeOrderService.getMessage(realTimeOrderId)); + } + /** + * 实时订单详情数据列表(PC) + * @param chargingOrderId + * @return + */ + @GetMapping("/timeList") + public TableDataInfo timeList(@RequestParam Long chargingOrderId) + { + startPage(); + List> list = xhpcRealTimeOrderService.timeList(chargingOrderId); + return getDataTable(list); + } + + /** + * 实时订单详情数据图表(PC) + * @param chargingOrderId + * @return + */ + @GetMapping("/timeChartList") + public AjaxResult timeChartList(@RequestParam Long chargingOrderId) + { + return xhpcRealTimeOrderService.timeChartList(chargingOrderId); + } + + } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/HxpcChargeOrderMapper.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/HxpcChargeOrderMapper.java index 4faafb48..20f336d7 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/HxpcChargeOrderMapper.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/HxpcChargeOrderMapper.java @@ -18,7 +18,7 @@ public interface HxpcChargeOrderMapper { * @param userId * @return */ - Map getHistotyChargeOrderMessage(@Param("userId") Long userId); + int getHistotyChargeOrderMessage(@Param("userId") Long userId); /** * 异常订单 diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcHistoryOrderMapper.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcHistoryOrderMapper.java index 1bf0b4ce..525d48a6 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcHistoryOrderMapper.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcHistoryOrderMapper.java @@ -68,5 +68,5 @@ public interface XhpcHistoryOrderMapper { * @param historyOrderId * @return */ - Map gethistotyOrderMessage(@Param("userId") Long userId, @Param("historyOrderId") Long historyOrderId); + Map gethistotyOrderMessage(@Param("userId") Long userId, @Param("historyOrderId") Long historyOrderId, @Param("type") Integer type, @Param("chargingOrderId") Long chargingOrderId); } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcRealTimeOrderMapper.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcRealTimeOrderMapper.java index 11e89edd..cf9efbb6 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcRealTimeOrderMapper.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcRealTimeOrderMapper.java @@ -4,6 +4,7 @@ import com.xhpc.order.domain.XhpcChargeOrderSoc; import com.xhpc.order.domain.XhpcRealTimeOrder; import org.apache.ibatis.annotations.Param; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -43,4 +44,40 @@ public interface XhpcRealTimeOrderMapper { * @return */ List> list(@Param("phone") String phone,@Param("transactionNumber") String transactionNumber,@Param("source") Integer source,@Param("chargingStationName") String chargingStationName,@Param("terminalName")String terminalName,@Param("operatorId") Long operatorId,@Param("startTime") String startTime,@Param("endTime") String endTime,@Param("type") Integer type); + + /** + * 实时订单详情接口(PC端) + * @param realTimeOrderId + * @return + */ + Map getMessage(@Param("realTimeOrderId")Long realTimeOrderId); + + + /** + * 实时订单详情数据列表(PC) + * @param chargingOrderId + * @return + */ + List> timeList(@Param("chargingOrderId")Long chargingOrderId); + + /** + * 实时订单详情数据图表SOC(PC) + * @param chargingOrderId + * @return + */ + Map timeChartSOCList(Long chargingOrderId); + + /** + * 实时订单详情数据图表电压(PC) + * @param chargingOrderId + * @return + */ + Map timeChartVoltageList(Long chargingOrderId); + + /** + * 实时订单详情数据图表电流(PC) + * @param chargingOrderId + * @return + */ + Map timeChartCurrentList(Long chargingOrderId); } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcHistoryOrderService.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcHistoryOrderService.java index 6aaa43bd..78cbb9ed 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcHistoryOrderService.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcHistoryOrderService.java @@ -26,5 +26,5 @@ public interface IXhpcHistoryOrderService { * @param historyOrderId * @return */ - AjaxResult gethistotyOrderMessage(Long userId,Long historyOrderId); + AjaxResult gethistotyOrderMessage(Long userId,Long historyOrderId,Integer type,Long chargingOrderId); } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcRealTimeOrderService.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcRealTimeOrderService.java index 86d5c62b..1126bdcd 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcRealTimeOrderService.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcRealTimeOrderService.java @@ -1,5 +1,8 @@ package com.xhpc.order.service; +import com.xhpc.common.core.web.domain.AjaxResult; + +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -18,7 +21,7 @@ public interface IXhpcRealTimeOrderService { /** - * 实时订单接口 + * 实时订单接口(PC端) * @param phone 用户账号 * @param transactionNumber 订单编号 * @param source 用户类型 0C端用户 1流量用户 @@ -31,5 +34,24 @@ public interface IXhpcRealTimeOrderService { */ List> list(String phone,String transactionNumber,Integer source,String chargingStationName,String terminalName,Long operatorId,String startTime,String endTime); + /** + * 实时订单详情接口(PC端) + * @param realTimeOrderId + * @return + */ + Map getMessage(Long realTimeOrderId); + /** + * 实时订单详情数据列表(PC) + * @param chargingOrderId 充电订单id + * @return + */ + List> timeList(Long chargingOrderId); + + /** + * 实时订单详情数据图表(PC) + * @param chargingOrderId + * @return + */ + AjaxResult timeChartList(Long chargingOrderId); } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/HxpcChargeOrderServiceImpl.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/HxpcChargeOrderServiceImpl.java index 3ac34c30..980eeb3a 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/HxpcChargeOrderServiceImpl.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/HxpcChargeOrderServiceImpl.java @@ -45,8 +45,11 @@ public class HxpcChargeOrderServiceImpl implements IHxpcChargeOrderService { @Override public AjaxResult getHistotyChargeOrderMessage(Long userId) { - - return AjaxResult.success(hxpcChargeOrderMapper.getHistotyChargeOrderMessage(userId)); + int count = hxpcChargeOrderMapper.getHistotyChargeOrderMessage(userId); + if(count>0){ + return AjaxResult.success(); + } + return AjaxResult.error(1201,"无实时数据"); } @Override diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcHistoryOrderServiceImpl.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcHistoryOrderServiceImpl.java index fcdd35a8..42af38a6 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcHistoryOrderServiceImpl.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcHistoryOrderServiceImpl.java @@ -3,6 +3,7 @@ package com.xhpc.order.service.impl; import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.order.mapper.XhpcHistoryOrderMapper; import com.xhpc.order.service.IXhpcHistoryOrderService; +import org.apache.poi.ss.formula.functions.T; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -24,8 +25,8 @@ public class XhpcHistoryOrderServiceImpl implements IXhpcHistoryOrderService { } @Override - public AjaxResult gethistotyOrderMessage(Long userId, Long historyOrderId) { - return AjaxResult.success(xhpcHistoryOrderMapper.gethistotyOrderMessage(userId,historyOrderId)); + public AjaxResult gethistotyOrderMessage(Long userId, Long historyOrderId,Integer type,Long chargingOrderId) { + return AjaxResult.success(xhpcHistoryOrderMapper.gethistotyOrderMessage(userId,historyOrderId,type,chargingOrderId)); } } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java index fa15c710..bc313b6e 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java @@ -1,11 +1,14 @@ package com.xhpc.order.service.impl; +import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.redis.service.RedisService; import com.xhpc.order.mapper.XhpcRealTimeOrderMapper; import com.xhpc.order.service.IXhpcRealTimeOrderService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -59,5 +62,24 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService { return xhpcRealTimeOrderMapper.list(phone,transactionNumber,source,chargingStationName,terminalName,operatorId,startTime,endTime,type); } + @Override + public Map getMessage(Long realTimeOrderId) { + return xhpcRealTimeOrderMapper.getMessage(realTimeOrderId); + } + + @Override + public List> timeList(Long chargingOrderId) { + return xhpcRealTimeOrderMapper.timeList(chargingOrderId); + } + + @Override + public AjaxResult timeChartList(Long chargingOrderId) { + Map map =new HashMap(); + map.put("soc",xhpcRealTimeOrderMapper.timeChartSOCList(chargingOrderId)); + map.put("voltage",xhpcRealTimeOrderMapper.timeChartVoltageList(chargingOrderId)); + map.put("soc",xhpcRealTimeOrderMapper.timeChartCurrentList(chargingOrderId)); + return AjaxResult.success(map); + } + } diff --git a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml index 91c68f00..c8b4aaa0 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml @@ -49,27 +49,35 @@ - + select + count(charge_order_id) + from xhpc_charge_order + where user_id = #{userId} and status=0 and del_flag =0 + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcRealTimeOrderMapper.xml b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcRealTimeOrderMapper.xml index 87377fbc..74024d9e 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcRealTimeOrderMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcRealTimeOrderMapper.xml @@ -202,23 +202,23 @@ + + + + + + + + + + \ No newline at end of file