diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/controller/XhpcChargingPileController.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/controller/XhpcChargingPileController.java index 9ac6ffdf..ddf05f28 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/controller/XhpcChargingPileController.java +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/controller/XhpcChargingPileController.java @@ -100,8 +100,10 @@ public class XhpcChargingPileController extends BaseController { @Log(title = "桩-停用", businessType = BusinessType.UPDATE) @PostMapping(value = "/updateStatus") public AjaxResult updateStatus(@RequestBody XhpcChargingPile xhpcChargingPile) { - if(null==xhpcChargingPile.getPrompt() || xhpcChargingPile.getPrompt().length()>50){ - return AjaxResult.error("桩提示语为空且50字之内"); + if(xhpcChargingPile.getStatus()==1){ + if(null==xhpcChargingPile.getPrompt() || xhpcChargingPile.getPrompt().length()>50){ + return AjaxResult.error("桩提示语为空且50字之内"); + } } return xhpcChargingPileService.updateStatus(xhpcChargingPile.getChargingPileId(), xhpcChargingPile.getStatus(),xhpcChargingPile.getPrompt()); } diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/controller/XhpcTerminalController.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/controller/XhpcTerminalController.java index 2987e97c..b509ddbe 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/controller/XhpcTerminalController.java +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/controller/XhpcTerminalController.java @@ -58,8 +58,10 @@ public class XhpcTerminalController extends BaseController { if(null==xhpcTerminal.getStatus()){ return AjaxResult.error("桩数据状态为空"); } - if(null==xhpcTerminal.getPrompt() || xhpcTerminal.getPrompt().length()>50){ - return AjaxResult.error("桩提示语为空且50字之内"); + if(xhpcTerminal.getStatus()==1){ + if(null==xhpcTerminal.getPrompt() || xhpcTerminal.getPrompt().length()>50){ + return AjaxResult.error("桩提示语为空且50字之内"); + } } return xhpcTerminalService.updateStatus(xhpcTerminal.getTerminalId(), xhpcTerminal.getStatus(),xhpcTerminal.getPrompt()); } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcStatisticsController.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcStatisticsController.java index 39422d04..e8d6fd3f 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcStatisticsController.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcStatisticsController.java @@ -432,7 +432,7 @@ public class XhpcStatisticsController extends BaseController { * @param type 1 近30天 2上个月 3本月 4.近12月 */ @GetMapping("/getWorkHistoryOrderList") - public AjaxResult getWorkHistoryOrderList(Long operatorId,Long chargingStationId,Long chargingPileId,Long terminalId,String stopReason,@RequestParam(value = "startTime")String startTime,@RequestParam(value = "endTime")String endTime,Integer type){ + public AjaxResult getWorkHistoryOrderList(Long operatorId,Long chargingStationId,Long chargingPileId,Long terminalId,String stopReason,@RequestParam(value = "startTime", required = true)String startTime,@RequestParam(value = "endTime", required = true)String endTime,Integer type){ return AjaxResult.success(xhpcStatisticsService.getWorkHistoryOrderList(operatorId,chargingStationId,chargingPileId,terminalId,stopReason,startTime,endTime,type)); } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcStopChargingOrderController.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcStopChargingOrderController.java index ffb8c28f..5768e86f 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcStopChargingOrderController.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcStopChargingOrderController.java @@ -54,16 +54,17 @@ public class XhpcStopChargingOrderController extends BaseController { //查询缓存是否该终端在充电 Map cacheMap = redisService.getCacheMap("gun:" + serialNumber); - if(cacheMap!=null){ + + Map serialNumberOrder = xhpcChargeOrderService.getSerialNumberOrder(serialNumber); + if(cacheMap !=null && serialNumberOrder!=null && serialNumberOrder.get("serialNumber") !=null){ if(cacheMap.get("orderkey") !=null){ - String orderNumber = cacheMap.get("orderkey").toString().substring(6); - String orderkey = cacheMap.get("orderkey").toString(); + String serialNumberOrderMap = serialNumberOrder.get("serialNumber").toString(); String version ="0A"; if(cacheMap.get("version") !=null){ version =cacheMap.get("version").toString(); } - R r = powerPileService.stopCharging(orderNumber, orderkey.substring(0,14), orderkey.substring(0,16), version); + R r = powerPileService.stopCharging(serialNumberOrderMap, serialNumberOrderMap.substring(0,14), serialNumberOrderMap.substring(0,16), version); if(r.getCode()==200){ return AjaxResult.success("停止充电命令已下发"); diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcChargeOrderMapper.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcChargeOrderMapper.java index 2aba4810..040d9300 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcChargeOrderMapper.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcChargeOrderMapper.java @@ -226,5 +226,5 @@ public interface XhpcChargeOrderMapper { List> select3rdNameBy(@Param(value = "operatorIdEvcs") String operatorIdEvcs); - + Map getSerialNumberOrder(@Param("serialNumber")String serialNumber); } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcChargeOrderService.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcChargeOrderService.java index 4bc18491..d196961f 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcChargeOrderService.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcChargeOrderService.java @@ -172,4 +172,7 @@ public interface IXhpcChargeOrderService { R cardStartup(Long userId,String serialNumber,Integer userType,String tenantId, Integer type, String grantOperator,String rateModelId); R pileVin(String serialNumber,String vinNumber); + + //根据终端号查询最近的一个在充电的订单 + Map getSerialNumberOrder(String serialNumber); } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java index c0f8eff2..65b84a55 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java @@ -1059,6 +1059,12 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar return R.fail(); } + @Override + public Map getSerialNumberOrder(String serialNumber) { + + return xhpcChargeOrderMapper.getSerialNumberOrder(serialNumber); + } + public static boolean isValidDate(String str) { try { if (0 != str.length()) { 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 ae1e9405..f9efbd28 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml @@ -725,4 +725,8 @@ + + diff --git a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcStatisticsMapper.xml b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcStatisticsMapper.xml index 8d8f119e..74d9e794 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcStatisticsMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcStatisticsMapper.xml @@ -1439,7 +1439,7 @@ xcs.`name` name, IFNULL(us.totalOrder,0) totalOrder, IFNULL(us.emptyorder,0) emptyorder, - IFNULL(us.emptyOrderRate,0) emptyOrderRate + concat(IFNULL(us.emptyOrderRate,0),'%') emptyOrderRate from xhpc_charging_station xcs LEFT JOIN( SELECT @@ -1479,6 +1479,7 @@ and find_in_set (xh.charging_station_id,(select station_ids from xhpc_work_user where work_user_id=#{logOperatorId})) GROUP BY xcs.charging_station_id) us on us.charging_station_id = xcs.charging_station_id + where xcs.del_flag =0 GROUP BY xcs.charging_station_id order by xcs.charging_station_id @@ -1488,12 +1489,13 @@ xte.`name` name, IFNULL(us.totalOrder,0) totalOrder, IFNULL(us.emptyorder,0) emptyorder, - IFNULL(us.emptyOrderRate,0) emptyOrderRate + concat(IFNULL(us.emptyOrderRate,0),'%') emptyOrderRate from xhpc_terminal xte LEFT JOIN(SELECT COUNT(xh.history_order_id) totalOrder, xt.`name` name, IFNULL(ut.empty,0) emptyorder, + xh.terminal_id, concat(format(ifnull(empty/COUNT(xh.history_order_id)*100,0), 2),'%') emptyOrderRate FROM `xhpc_history_order` as xh LEFT JOIN xhpc_charging_station xcs on xcs.charging_station_id =xh.charging_station_id @@ -1526,7 +1528,7 @@ and xh.charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{logOperatorId}) - GROUP BY xh.terminal_id) + GROUP BY xh.terminal_id)us on us.terminal_id = xte.terminal_id where xte.del_flag =0 and xte.charging_station_id = #{chargingStationId} GROUP BY xte.terminal_id diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcRechargeOrderMapper.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcRechargeOrderMapper.java index 07015d5e..24612529 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcRechargeOrderMapper.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcRechargeOrderMapper.java @@ -59,7 +59,7 @@ public interface XhpcRechargeOrderMapper { * @param createTimeEnd * @return */ - public String sumMoney(@Param("phone")String phone,@Param("rechargeOrderNumber") String rechargeOrderNumber,@Param("status") String status,@Param("createTimeStart") String createTimeStart,@Param("createTimeEnd") String createTimeEnd,@Param("type")Integer type,@Param("source")Integer source,@Param("userId")Integer userId,@Param("tenantId")String tenantId); + public Map sumMoney(@Param("phone")String phone,@Param("rechargeOrderNumber") String rechargeOrderNumber,@Param("status") String status,@Param("createTimeStart") String createTimeStart,@Param("createTimeEnd") String createTimeEnd,@Param("type")Integer type,@Param("source")Integer source,@Param("userId")Integer userId,@Param("tenantId")String tenantId,@Param("time1")String time1,@Param("time2")String time2,@Param("time3")String time3,@Param("time4")String time4); /** diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcRefundOrderMapper.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcRefundOrderMapper.java index 6e30aa8b..91d19a19 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcRefundOrderMapper.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcRefundOrderMapper.java @@ -76,7 +76,7 @@ public interface XhpcRefundOrderMapper { * @param createTimeEnd * @return */ - public String sumMoney(@Param("phone") String phone, @Param("refundOrderNumber") String refundOrderNumber, @Param("status") String status, @Param("createTimeStart") String createTimeStart, @Param("createTimeEnd") String createTimeEnd,@Param("type")Integer type,@Param("tenantId")String tenantId); + public Map sumMoney(@Param("phone") String phone, @Param("refundOrderNumber") String refundOrderNumber, @Param("status") String status, @Param("createTimeStart") String createTimeStart, @Param("createTimeEnd") String createTimeEnd,@Param("type")Integer type,@Param("tenantId")String tenantId,@Param("time1")String time1,@Param("time2")String time2,@Param("time3")String time3,@Param("time4")String time4); diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/IXhpcRechargeOrderService.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/IXhpcRechargeOrderService.java index 0c1a0c7d..bba2f2ec 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/IXhpcRechargeOrderService.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/IXhpcRechargeOrderService.java @@ -66,7 +66,7 @@ public interface IXhpcRechargeOrderService { * @param createTimeEnd * @return */ - public String sumMoney(String phone, String rechargeOrderNumber, String status, String createTimeStart, String createTimeEnd,Integer type,Integer source,Integer userId); + public Map sumMoney(String phone, String rechargeOrderNumber, String status, String createTimeStart, String createTimeEnd,Integer type,Integer source,Integer userId); /** * 新增 充值订单 diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/IXhpcRefundOrderService.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/IXhpcRefundOrderService.java index a38cf1b7..f839cd2e 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/IXhpcRefundOrderService.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/IXhpcRefundOrderService.java @@ -68,7 +68,7 @@ public interface IXhpcRefundOrderService { * @param createTimeEnd * @return */ - public String sumMoney(String phone, String refundOrderNumber, String status, String createTimeStart, String createTimeEnd,Integer type); + public Map sumMoney(String phone, String refundOrderNumber, String status, String createTimeStart, String createTimeEnd,Integer type); /** * 新增 退款订单 diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRechargeOrderServiceImpl.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRechargeOrderServiceImpl.java index 9d9263ae..13fb8f54 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRechargeOrderServiceImpl.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRechargeOrderServiceImpl.java @@ -1,5 +1,7 @@ package com.xhpc.payment.service.impl; +import cn.hutool.core.date.DateField; +import cn.hutool.core.date.DateUtil; import cn.hutool.core.io.IoUtil; import cn.hutool.poi.excel.BigExcelWriter; import cn.hutool.poi.excel.ExcelUtil; @@ -121,9 +123,21 @@ public class XhpcRechargeOrderServiceImpl implements IXhpcRechargeOrderService { @Override - public String sumMoney(String phone, String rechargeOrderNumber, String status, String createTimeStart, String createTimeEnd, Integer type,Integer source,Integer userId) { + public Map sumMoney(String phone, String rechargeOrderNumber, String status, String createTimeStart, String createTimeEnd, Integer type,Integer source,Integer userId) { LoginUser loginUser = tokenService.getLoginUser(); - return xhpcRechargeOrderMapper.sumMoney(phone, rechargeOrderNumber, status, createTimeStart, createTimeEnd, type,source,userId,loginUser.getTenantId()); + //昨日用户的活跃度 + Date newDate1 = DateUtil.offset(new Date(), DateField.DAY_OF_MONTH, -1); + String time1 = DateUtil.format(newDate1, "yyyy-MM-dd HH:mm:ss"); + //7天用户的活跃度 + Date newDate2 = DateUtil.offset(new Date(), DateField.DAY_OF_MONTH, -7); + String time2 = DateUtil.format(newDate2, "yyyy-MM-dd HH:mm:ss"); + //一个月用户的活跃度 + Date newDate3 = DateUtil.offset(new Date(), DateField.DAY_OF_MONTH, -30); + String time3 = DateUtil.format(newDate3, "yyyy-MM-dd HH:mm:ss"); + //3个月天用户的活跃度 + Date newDate4 = DateUtil.offset(new Date(), DateField.DAY_OF_MONTH, -90); + String time4 = DateUtil.format(newDate4, "yyyy-MM-dd HH:mm:ss"); + return xhpcRechargeOrderMapper.sumMoney(phone, rechargeOrderNumber, status, createTimeStart, createTimeEnd, type,source,userId,loginUser.getTenantId(),time1,time2,time3,time4); } /** diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRefundOrderServiceImpl.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRefundOrderServiceImpl.java index c945660e..8da124c1 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRefundOrderServiceImpl.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRefundOrderServiceImpl.java @@ -1,5 +1,7 @@ package com.xhpc.payment.service.impl; +import cn.hutool.core.date.DateField; +import cn.hutool.core.date.DateUtil; import cn.hutool.core.io.IoUtil; import cn.hutool.poi.excel.BigExcelWriter; import cn.hutool.poi.excel.ExcelUtil; @@ -129,9 +131,22 @@ public class XhpcRefundOrderServiceImpl implements IXhpcRefundOrderService { } @Override - public String sumMoney(String phone, String refundOrderNumber, String status, String createTimeStart, String createTimeEnd, Integer type) { + public Map sumMoney(String phone, String refundOrderNumber, String status, String createTimeStart, String createTimeEnd, Integer type) { LoginUser loginUser = tokenService.getLoginUser(); - return xhpcRefundOrderMapper.sumMoney(phone, refundOrderNumber, status, createTimeStart, createTimeEnd, type,loginUser.getTenantId()); + //昨日用户的活跃度 + Date newDate1 = DateUtil.offset(new Date(), DateField.DAY_OF_MONTH, -1); + String time1 = DateUtil.format(newDate1, "yyyy-MM-dd HH:mm:ss"); + //7天用户的活跃度 + Date newDate2 = DateUtil.offset(new Date(), DateField.DAY_OF_MONTH, -7); + String time2 = DateUtil.format(newDate2, "yyyy-MM-dd HH:mm:ss"); + //一个月用户的活跃度 + Date newDate3 = DateUtil.offset(new Date(), DateField.DAY_OF_MONTH, -30); + String time3 = DateUtil.format(newDate3, "yyyy-MM-dd HH:mm:ss"); + //3个月天用户的活跃度 + Date newDate4 = DateUtil.offset(new Date(), DateField.DAY_OF_MONTH, -90); + String time4 = DateUtil.format(newDate4, "yyyy-MM-dd HH:mm:ss"); + + return xhpcRefundOrderMapper.sumMoney(phone, refundOrderNumber, status, createTimeStart, createTimeEnd, type,loginUser.getTenantId(),time1,time2,time3,time4); } /** diff --git a/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRechargeOrderMapper.xml b/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRechargeOrderMapper.xml index ef0d6249..e62c22dc 100644 --- a/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRechargeOrderMapper.xml +++ b/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRechargeOrderMapper.xml @@ -212,8 +212,14 @@ ORDER BY xro.create_time DESC - + select + sum(xro.amount) amount, + (select sum(amount) from xhpc_recharge_order where create_time >= #{time1} and tenant_id =#{tenantId} and del_flag = 0 and status=1) one, + (select sum(amount) from xhpc_recharge_order where create_time >= #{time2} and tenant_id =#{tenantId} and del_flag = 0 and status=1) two, + (select sum(amount) from xhpc_recharge_order where create_time >= #{time3} and tenant_id =#{tenantId} and del_flag = 0 and status=1) three, + (select sum(amount) from xhpc_recharge_order where create_time >= #{time4} and tenant_id =#{tenantId} and del_flag = 0 and status=1) four + from xhpc_recharge_order xro LEFT JOIN xhpc_app_user xau on xau.app_user_id = xro.user_id LEFT JOIN sys_dict_data sdd on sdd.`dict_type` = 'recharge_order_status' and sdd.dict_value = xro.`status` diff --git a/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRefundOrderMapper.xml b/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRefundOrderMapper.xml index 455005de..2eb018f4 100644 --- a/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRefundOrderMapper.xml +++ b/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRefundOrderMapper.xml @@ -244,8 +244,13 @@ ORDER BY xro.create_time DESC - + select + sum(xro.amount) amount, + (select sum(amount) from xhpc_refund_order where create_time >= #{time1} and tenant_id =#{tenantId} and del_flag = 0 and examine_status=1 and status =1) one, + (select sum(amount) from xhpc_refund_order where create_time >= #{time2} and tenant_id =#{tenantId} and del_flag = 0 and examine_status=1 and status =1) two, + (select sum(amount) from xhpc_refund_order where create_time >= #{time3} and tenant_id =#{tenantId} and del_flag = 0 and examine_status=1 and status =1) three, + (select sum(amount) from xhpc_refund_order where create_time >= #{time4} and tenant_id =#{tenantId} and del_flag = 0 and examine_status=1 and status =1) four from xhpc_refund_order xro LEFT JOIN xhpc_app_user xau on xau.app_user_id = xro.user_id LEFT JOIN sys_dict_data sdd on sdd.`dict_type` = 'refund_order_status' and sdd.dict_value = xro.`status`