From b20365948eb9130e8cbfa72f2af382ad03d9c35a Mon Sep 17 00:00:00 2001 From: "2265829957@qq.com" <2265829957@qq.com> Date: Tue, 13 May 2025 09:35:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=A0=E4=BD=8D=E8=B4=B9=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NotificationChargeOrderInfoTask.java | 3 +- .../api/XhpcChargingStationApiController.java | 7 +- .../mapper/XhpcChargingStationMapper.java | 2 + .../station/mapper/XhpcRateTimeMapper.java | 2 + .../station/mapper/XhpcTerminalMapper.java | 2 + .../service/IXhpcChargingStationService.java | 1 + .../station/service/IXhpcRateTimeService.java | 3 + .../XhpcChargingStationServiceImpl.java | 96 +-- .../service/XhpcTerminalServiceImpl.java | 8 +- .../mapper/XhpcChargingStationMapper.xml | 61 +- .../mapper/XhpcPlaceholderMapper.xml | 6 + .../resources/mapper/XhpcTerminalMapper.xml | 22 +- .../common/domain/XhpcPlaceholderTime.java | 1 - .../order/domain/XhpcPlaceholderOrder.java | 5 +- .../XhpcPileRegularInspectController.java | 7 +- .../XhpcPlaceholderOrderController.java | 95 +++ .../dto/XhpcPlaceholderTimeOrderDto.java | 26 + .../mapper/XhpcPlaceholderOrderMapper.java | 35 + .../order/mapper/XhpcRealTimeOrderMapper.java | 1 - .../service/IXhpcPlaceholderOrderService.java | 26 + .../impl/XhpcPlaceholderOrderServiceImpl.java | 419 ++++++++++++ .../impl/XhpcRealTimeOrderServiceImpl.java | 11 +- .../mapper/XhpcPlaceholderOrderMapper.xml | 637 ++++++++++++++++++ .../mapper/XhpcRealTimeOrderMapper.xml | 185 +---- .../com/xhpc/pp/logic/RealtimeDataLogic.java | 7 +- 25 files changed, 1403 insertions(+), 265 deletions(-) create mode 100644 xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcPlaceholderOrderController.java create mode 100644 xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/dto/XhpcPlaceholderTimeOrderDto.java create mode 100644 xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcPlaceholderOrderMapper.java create mode 100644 xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcPlaceholderOrderService.java create mode 100644 xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcPlaceholderOrderServiceImpl.java create mode 100644 xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcPlaceholderOrderMapper.xml diff --git a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationChargeOrderInfoTask.java b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationChargeOrderInfoTask.java index 8a7e43d1..2d0b6e2d 100644 --- a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationChargeOrderInfoTask.java +++ b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/notification/NotificationChargeOrderInfoTask.java @@ -82,11 +82,12 @@ public class NotificationChargeOrderInfoTask extends CoreDispatcher { // horder.setXhpcStatisticsTimeIntervalList(statisticsTimeIntervals); //似乎并不需要 ChargeOrderInfo chargeOrderInfo = new ChargeOrderInfo(horder); final ChargeOrderInfoResponse pushResp = notify(chargeOrderInfo, authSecretToken); + logger.info("==============推送开始======================="+horder.getSerialNumber()); if (pushResp != null) { horder.setConfirmResult(pushResp.getConfirmResult()); logger.debug("3rd part order {} push result: {}", horder.getSerialNumber(), pushResp.getConfirmResult()); - //logger.info("==============推送返回值================="+pushResp.toString()); + logger.info("==============推送返回值================="+pushResp.getConfirmResult()+"=========="+horder.getSerialNumber()); xhpcHistoryOrderRepository.save(horder); REDIS.setCacheMapValue("pushOrder:".concat(horder.getSerialNumber()), "horderpushed", true); } else { diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/api/XhpcChargingStationApiController.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/api/XhpcChargingStationApiController.java index c8e7dc85..8108f9d5 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/api/XhpcChargingStationApiController.java +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/api/XhpcChargingStationApiController.java @@ -88,9 +88,10 @@ public class XhpcChargingStationApiController extends BaseController { } + @GetMapping(value = "/getPlaceholderTimeMassage") + public AjaxResult getPlaceholderTimeMassage(@RequestParam Long chargingStationId) { - - - + return AjaxResult.success(xhpcChargingStationService.getPlaceholderTimeMassage(chargingStationId)); + } } diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/mapper/XhpcChargingStationMapper.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/mapper/XhpcChargingStationMapper.java index dc87b941..63154251 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/mapper/XhpcChargingStationMapper.java +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/mapper/XhpcChargingStationMapper.java @@ -162,7 +162,9 @@ public interface XhpcChargingStationMapper { */ List> getWXXhpcRateTimeMassage(@Param("chargingStationId") Long chargingStationId); + List> getPlaceholderTimeMassage(@Param("chargingStationId") Long chargingStationId); + Map getPlaceholderTime(@Param("date") String date, @Param("datchargingStationId") Long datchargingStationId); /** * 电站详情---终端列表 * diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/mapper/XhpcRateTimeMapper.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/mapper/XhpcRateTimeMapper.java index 77a30d78..412bac90 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/mapper/XhpcRateTimeMapper.java +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/mapper/XhpcRateTimeMapper.java @@ -34,4 +34,6 @@ public interface XhpcRateTimeMapper { Map getXhpcRateTimeType(@Param("datchargingStationId") Long datchargingStationId); + + } diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/mapper/XhpcTerminalMapper.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/mapper/XhpcTerminalMapper.java index b4cf3730..a8f43e86 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/mapper/XhpcTerminalMapper.java +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/mapper/XhpcTerminalMapper.java @@ -129,4 +129,6 @@ public interface XhpcTerminalMapper { */ List selectXhpcTerminalIdByPileIds(ArrayList pileIds); + + Map getPlaceholderTime(@Param("date") String date, @Param("datchargingStationId") Long datchargingStationId); } diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/IXhpcChargingStationService.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/IXhpcChargingStationService.java index f88e8662..197bcdfb 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/IXhpcChargingStationService.java +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/IXhpcChargingStationService.java @@ -173,6 +173,7 @@ public interface IXhpcChargingStationService { */ List> getWXXhpcTerminalMassage(Long chargingStationId); + List> getPlaceholderTimeMassage(Long chargingStationId); /** * 编辑电站(基本信息) * diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/IXhpcRateTimeService.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/IXhpcRateTimeService.java index 84dc664a..654fd42d 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/IXhpcRateTimeService.java +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/IXhpcRateTimeService.java @@ -21,4 +21,7 @@ public interface IXhpcRateTimeService { */ public Map getXhpcRateTime(String date, Long datchargingStationIde); + + + } diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingStationServiceImpl.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingStationServiceImpl.java index 3ce8985a..3633dfb7 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingStationServiceImpl.java +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingStationServiceImpl.java @@ -904,55 +904,59 @@ public class XhpcChargingStationServiceImpl extends BaseService implements IXhpc } else { map.put("imgIdList", new ArrayList<>()); } - //获取该时段电费 - //HH:mm:ss - String tiem = DateUtil.formatTime(new Date()); - Map xhpcRateTime = xhpcRateTimeService.getXhpcRateTime(tiem, chargingStationId); - if (xhpcRateTime != null) { - //桩(空闲和使用从redis获取) - BigDecimal serviceFee =new BigDecimal(xhpcRateTime.get("serviceFee").toString()); - BigDecimal powerFee =new BigDecimal(xhpcRateTime.get("powerFee").toString()); - if(loginUser !=null){ - System.out.println("==111======用户登录======"); - //判断是否享受活动 - Map objectMap = activityDiscountTime(loginUser.getUserid(), new Date(), loginUser.getUserType(), Long.valueOf(map.get("chargingStationId").toString()), loginUser.getTenantId()); - if("1".equals(objectMap.get("state").toString())){ - if("1".equals(objectMap.get("totalDiscountType").toString())||"3".equals(objectMap.get("totalDiscountType").toString())){ - BigDecimal discountRate = new BigDecimal(objectMap.get("totalDiscountRate").toString()).divide(new BigDecimal(100),2, BigDecimal.ROUND_HALF_UP); - serviceFee = serviceFee.subtract(serviceFee.multiply(discountRate).setScale(2,BigDecimal.ROUND_HALF_UP)); - powerFee = powerFee.subtract(powerFee.multiply(discountRate).setScale(2,BigDecimal.ROUND_HALF_UP)); - map.put("activityServiceFee", serviceFee); - map.put("activityPowerFee", powerFee); - map.put("activityMoney", serviceFee.add(powerFee)); - }else if ("3".equals(objectMap.get("totalDiscountType").toString())){ - BigDecimal discountRate = new BigDecimal(objectMap.get("totalDiscountRate").toString()).divide(new BigDecimal(100),2, BigDecimal.ROUND_HALF_UP); - serviceFee = serviceFee.subtract(serviceFee.multiply(discountRate).divide(new BigDecimal(2),2,BigDecimal.ROUND_HALF_UP)); - map.put("activityServiceFee", serviceFee); - map.put("activityPowerFee", powerFee); - map.put("activityMoney", serviceFee.add(powerFee)); - }else{ - BigDecimal discountRate = new BigDecimal(objectMap.get("totalDiscountRate").toString()).divide(new BigDecimal(100),2, BigDecimal.ROUND_HALF_UP); - serviceFee = serviceFee.subtract(serviceFee.multiply(discountRate).setScale(2,BigDecimal.ROUND_HALF_UP)); - map.put("activityServiceFee", serviceFee); - map.put("activityPowerFee", powerFee); - map.put("activityMoney", serviceFee.add(powerFee)); - } - if(objectMap.get("appletActivityName") !=null && !"".equals(objectMap.get("appletActivityName").toString())){ - map.put("appletActivityName", objectMap.get("appletActivityName").toString()); - }else{ - map.put("appletActivityName", ""); - } - map.put("activityState", 1); + String tiem = DateUtil.formatTime(new Date()); + Map xhpcRateTime = xhpcRateTimeService.getXhpcRateTime(tiem, chargingStationId); + if (xhpcRateTime != null) { + //桩(空闲和使用从redis获取) + BigDecimal serviceFee =new BigDecimal(xhpcRateTime.get("serviceFee").toString()); + BigDecimal powerFee =new BigDecimal(xhpcRateTime.get("powerFee").toString()); + if(loginUser !=null){ + System.out.println("==111======用户登录======"); + //判断是否享受活动 + Map objectMap = activityDiscountTime(loginUser.getUserid(), new Date(), loginUser.getUserType(), Long.valueOf(map.get("chargingStationId").toString()), loginUser.getTenantId()); + if("1".equals(objectMap.get("state").toString())){ + if("1".equals(objectMap.get("totalDiscountType").toString())||"3".equals(objectMap.get("totalDiscountType").toString())){ + BigDecimal discountRate = new BigDecimal(objectMap.get("totalDiscountRate").toString()).divide(new BigDecimal(100),2, BigDecimal.ROUND_HALF_UP); + serviceFee = serviceFee.subtract(serviceFee.multiply(discountRate).setScale(2,BigDecimal.ROUND_HALF_UP)); + powerFee = powerFee.subtract(powerFee.multiply(discountRate).setScale(2,BigDecimal.ROUND_HALF_UP)); + map.put("activityServiceFee", serviceFee); + map.put("activityPowerFee", powerFee); + map.put("activityMoney", serviceFee.add(powerFee)); + }else if ("3".equals(objectMap.get("totalDiscountType").toString())){ + BigDecimal discountRate = new BigDecimal(objectMap.get("totalDiscountRate").toString()).divide(new BigDecimal(100),2, BigDecimal.ROUND_HALF_UP); + serviceFee = serviceFee.subtract(serviceFee.multiply(discountRate).divide(new BigDecimal(2),2,BigDecimal.ROUND_HALF_UP)); + map.put("activityServiceFee", serviceFee); + map.put("activityPowerFee", powerFee); + map.put("activityMoney", serviceFee.add(powerFee)); }else{ - System.out.println("==222======用户登录======"); - map.put("activityState", 0); + BigDecimal discountRate = new BigDecimal(objectMap.get("totalDiscountRate").toString()).divide(new BigDecimal(100),2, BigDecimal.ROUND_HALF_UP); + serviceFee = serviceFee.subtract(serviceFee.multiply(discountRate).setScale(2,BigDecimal.ROUND_HALF_UP)); + map.put("activityServiceFee", serviceFee); + map.put("activityPowerFee", powerFee); + map.put("activityMoney", serviceFee.add(powerFee)); } + if(objectMap.get("appletActivityName") !=null && !"".equals(objectMap.get("appletActivityName").toString())){ + map.put("appletActivityName", objectMap.get("appletActivityName").toString()); + }else{ + map.put("appletActivityName", ""); + } + map.put("activityState", 1); }else{ - System.out.println("===333=====用户登录======"); + System.out.println("==222======用户登录======"); map.put("activityState", 0); } - map.putAll(xhpcRateTime); + }else{ + System.out.println("===333=====用户登录======"); + map.put("activityState", 0); } + map.putAll(xhpcRateTime); + } + //获取该时段占位费电费 + Map placeholderTime = xhpcChargingStationMapper.getPlaceholderTime(tiem, chargingStationId); + if(placeholderTime !=null){ + map.putAll(placeholderTime); + } + }catch (Exception e){ e.printStackTrace(); } @@ -1007,6 +1011,12 @@ public class XhpcChargingStationServiceImpl extends BaseService implements IXhpc return list; } + @Override + public List> getPlaceholderTimeMassage(Long chargingStationId) { + List> list = xhpcChargingStationMapper.getPlaceholderTimeMassage(chargingStationId); + return list; + } + @Override public List> getWXXhpcTerminalMassage(Long chargingStationId) { diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcTerminalServiceImpl.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcTerminalServiceImpl.java index a11a5ccd..db82b343 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcTerminalServiceImpl.java +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcTerminalServiceImpl.java @@ -134,10 +134,16 @@ public class XhpcTerminalServiceImpl extends BaseService implements IXhpcTermina if (map == null || map.get("chargingStationId") == null) { return AjaxResult.error(1007, "无效的终端编码"); } + String tiem = DateUtil.formatTime(new Date()); + //获取桩的状态 Long chargingStationId = Long.parseLong(map.get("chargingStationId").toString()); //HH:mm:ss - String tiem = DateUtil.formatTime(new Date()); + //获取该时段占位费电费 + Map placeholderTime = xhpcTerminalMapper.getPlaceholderTime(tiem, chargingStationId); + if(placeholderTime !=null){ + map.putAll(placeholderTime); + } Map xhpcRateTime = xhpcRateTimeService.getXhpcRateTime(tiem, chargingStationId); LoginUser loginUser = tokenService.getLoginUser(); 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 62a2ac29..82d18741 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 @@ -512,6 +512,7 @@ cs.name as name, cs.longitude as longitude, cs.latitude as latitude, + xp.content as content, cs.parking_instructions as parkingInstructions, cs.detailed_address as detailedAddress, cs.service_facilities as serviceFacilities, @@ -528,7 +529,7 @@ from xhpc_charging_station as cs left JOIN xhpc_rate_time as xrt on xrt.charging_station_id =cs.charging_station_id and cs.rate_model_id = xrt.rate_model_id and xrt.start_time <= #{date} and replace(xrt.end_time, '00:00:00', '24:00:00') >= #{date} and xrt.status = 0 and xrt.del_flag = 0 LEFT JOIN xhpc_rate as ra on ra.rate_id =xrt.rate_id - + LEFT JOIN xhpc_placeholder as xp on xp.charging_station_id =cs.charging_station_id and xp.status =1 and xp.del_flag =0 where cs.del_flag =0 and cs.status =0 and FIND_IN_SET(#{clientVisible},cs.client_visible)>0 @@ -562,8 +563,11 @@ + + + + + + diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/domain/XhpcPlaceholderTime.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/domain/XhpcPlaceholderTime.java index 78ec9d98..89c0f655 100644 --- a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/domain/XhpcPlaceholderTime.java +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/domain/XhpcPlaceholderTime.java @@ -1,6 +1,5 @@ package com.xhpc.common.domain; -import com.xhpc.common.core.annotation.Excel; import com.xhpc.common.core.web.domain.BaseEntity; import lombok.Data; diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/order/domain/XhpcPlaceholderOrder.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/order/domain/XhpcPlaceholderOrder.java index 388c675f..cbc69cef 100644 --- a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/order/domain/XhpcPlaceholderOrder.java +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/order/domain/XhpcPlaceholderOrder.java @@ -43,7 +43,10 @@ public class XhpcPlaceholderOrder extends BaseEntity { private BigDecimal totalMoney; private BigDecimal price; private String tenantId; - + private String delFlag; + private String chargingMode; + private String driverId; + private String plateNum; public XhpcPlaceholderOrder() { } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcPileRegularInspectController.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcPileRegularInspectController.java index 54880b3b..7f806abc 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcPileRegularInspectController.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcPileRegularInspectController.java @@ -60,12 +60,7 @@ public class XhpcPileRegularInspectController extends BaseController { //定期抄发管理员定时任务 - //占位费定时任务 - @Scheduled(cron = "0/10 * * * * ? ") - public void getxhpcPlaceholderOrderTime() - { - xhpcPileRegularInspectService.getTimingPriceTime(); - } + diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcPlaceholderOrderController.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcPlaceholderOrderController.java new file mode 100644 index 00000000..fb6df8b9 --- /dev/null +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcPlaceholderOrderController.java @@ -0,0 +1,95 @@ +package com.xhpc.order.controller; + +import com.xhpc.common.core.domain.R; +import com.xhpc.common.core.web.controller.BaseController; +import com.xhpc.common.core.web.domain.AjaxResult; +import com.xhpc.common.core.web.page.TableDataInfo; +import com.xhpc.order.service.IXhpcPlaceholderOrderService; +import io.swagger.annotations.Api; +import io.swagger.annotations.Scope; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** + * 占位费订单 + * + * @author yuyang + * @Date 2025-05-06 10:06 + */ +@EnableScheduling +@RestController +@RequestMapping("/placeholderOrder") +@Api(value = "占位费订单", tags = "占位费订单") +public class XhpcPlaceholderOrderController extends BaseController { + + @Resource + IXhpcPlaceholderOrderService xhpcPlaceholderOrderService; + + + @GetMapping("/getListPage") + public TableDataInfo getListPage(String tenantId, Long chargingStationId, Long chargingPileId, Long terminalId, String phone, String transactionNumber, @RequestParam("status")Integer status, String chargingStationName, Long operatorId, Integer source, String beginStartTime, String beginEndTime, @RequestParam("userId") Long userId, Integer type, + String affiliationOrganization, String evcsOrderNo, String plateNum, Integer internetId, String internetSerialNumber, String terminalName, String vinCode, String overStartTime, String overEndTime, Long personnelId, Integer confirmResult) + + { + List> listPage = xhpcPlaceholderOrderService.getListPage(tenantId,chargingStationId,chargingPileId,terminalId,phone, transactionNumber, status, chargingStationName, operatorId, source, beginStartTime, beginEndTime, userId, type, affiliationOrganization,evcsOrderNo,plateNum,internetId,internetSerialNumber,terminalName,vinCode,overStartTime,overEndTime,personnelId,confirmResult); + return getDataTable(listPage); + } + + + /** + * 历史订单导出 + * @param response 返回数据流 + * @throws IOException 文件创建异常 + */ + @PostMapping("/export") + public void getExport(HttpServletResponse response, + String tenantId, + Long chargingStationId, + Long chargingPileId, + Long terminalId, + String phone, + String transactionNumber, + @RequestParam("status")Integer status, + String chargingStationName, + Long operatorId, + Integer source, + String beginStartTime, + String beginEndTime, + @RequestParam("userId") Long userId, + Integer type, + String affiliationOrganization, + String evcsOrderNo, + String plateNum, + Integer internetId, + String internetSerialNumber, + String terminalName, + String vinCode, + String overStartTime, + String overEndTime, + Long personnelId, + Integer confirmResult) throws IOException { + + xhpcPlaceholderOrderService.export(response,tenantId,chargingStationId,chargingPileId,terminalId, phone, transactionNumber, status, chargingStationName, operatorId, source, beginStartTime, beginEndTime, userId, type,affiliationOrganization,evcsOrderNo,plateNum,internetId,internetSerialNumber,terminalName,vinCode,overStartTime,overEndTime,personnelId,confirmResult); + } + + + @GetMapping("/getById") + public R getById(@RequestParam("placeholderOrderId")Long placeholderOrderId){ + return xhpcPlaceholderOrderService.getById(placeholderOrderId); + } + + //定时任务,查询状态 + @Scheduled(cron = "0/30 * * * * ? ") + public void getxhpcPlaceholderOrderTime() { + xhpcPlaceholderOrderService.getTimingPriceTime(); + } + + +} diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/dto/XhpcPlaceholderTimeOrderDto.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/dto/XhpcPlaceholderTimeOrderDto.java new file mode 100644 index 00000000..c4255be7 --- /dev/null +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/dto/XhpcPlaceholderTimeOrderDto.java @@ -0,0 +1,26 @@ +package com.xhpc.order.dto; + +import com.xhpc.common.core.web.domain.BaseEntity; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author yuyang + * @Date 2025-05-09 12:00 + */ +@Data +public class XhpcPlaceholderTimeOrderDto extends BaseEntity { + + private Long placeholderTimeOrderId; + private Long placeholderOrderId; + private Date startTime; + private Date endTime; + private BigDecimal price; + private String delFlag; + private String tenantId; + private BigDecimal totalMoney; + private Integer totalTimeSpan; + +} diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcPlaceholderOrderMapper.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcPlaceholderOrderMapper.java new file mode 100644 index 00000000..1a37e292 --- /dev/null +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcPlaceholderOrderMapper.java @@ -0,0 +1,35 @@ +package com.xhpc.order.mapper; + +import com.xhpc.common.domain.XhpcPlaceholderTime; +import com.xhpc.order.domain.XhpcPlaceholderOrder; +import com.xhpc.order.dto.XhpcPlaceholderTimeOrderDto; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + +/** + * @author yuyang + * @Date 2025-05-06 11:16 + */ +public interface XhpcPlaceholderOrderMapper { + int insertXhpcPlaceholderOrder(XhpcPlaceholderOrder placeholderOrder ); + + XhpcPlaceholderOrder getXhpcPlaceholderOrderSerialNumber(@Param("serialNumber") String serialNumber); + + List getXhpcPlaceholderTime(@Param("startTime") String startTime,@Param("endTime") String endTime,@Param("placeholderId")Long placeholderId); + + int updateXhpcPlaceholderOrder(XhpcPlaceholderOrder placeholderOrder ); + + List> getListPage(@Param("chargingStationId")Long chargingStationId, @Param("chargingPileId")Long chargingPileId, @Param("terminalId")Long terminalId, @Param("phone")String phone, @Param("transactionNumber")String transactionNumber, @Param("status")Integer status, @Param("chargingStationName")String chargingStationName, @Param("operatorId")Long operatorId, @Param("source")Integer source, @Param("beginStartTime")String beginStartTime, @Param("beginEndTime")String beginEndTime, @Param("userId")Long userId, @Param("type")Integer type, @Param("number")Integer number, @Param("affiliationOrganization")String affiliationOrganization, @Param("evcsOrderNo")String evcsOrderNo, @Param("plateNum")String plateNum, @Param("internetId")Integer internetId, @Param("internetSerialNumber")String internetSerialNumber, @Param("terminalName")String terminalName, @Param("vinCode")String vinCode, @Param("overStartTime")String overStartTime, @Param("overEndTime")String overEndTime, @Param("personnelId")Long personnelId, @Param("confirmResult")Integer confirmResult, @Param("tenantId")String tenantId, @Param("isNotNull")Integer isNotNull); + + Map getById(@Param("placeholderOrderId")Long placeholderOrderId); + + int insertXhpcPlaceholderTimeOrder(XhpcPlaceholderTimeOrderDto xhpcPlaceholderTimeOrderDto); + + + int deleteByPlaceholderOrderIdInt(@Param("placeholderOrderId")Long placeholderOrderId); + + List> getXhpcPlaceholderTimeOrder(@Param("placeholderOrderId")Long placeholderOrderId); + +} 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 fb9b68d8..49e3689a 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 @@ -217,5 +217,4 @@ public interface XhpcRealTimeOrderMapper { //查询该场站是否有占位费设置 Map getXhpcPlaceholder(@Param("chargingStationId")Long chargingStationId); - int insertXhpcPlaceholderOrder(XhpcPlaceholderOrder placeholderOrder ); } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcPlaceholderOrderService.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcPlaceholderOrderService.java new file mode 100644 index 00000000..ed9681d2 --- /dev/null +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcPlaceholderOrderService.java @@ -0,0 +1,26 @@ +package com.xhpc.order.service; + +import com.xhpc.common.core.domain.R; +import com.xhpc.order.domain.XhpcPlaceholderOrder; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** + * @author yuyang + * @Date 2025-05-06 10:07 + */ +public interface IXhpcPlaceholderOrderService { + + int insertXhpcPlaceholderOrder(XhpcPlaceholderOrder placeholderOrder ); + + void getTimingPriceTime(); + + List> getListPage(String tenantId, Long chargingStationId, Long chargingPileId, Long terminalId, String phone, String transactionNumber, Integer status, String chargingStationName, Long operatorId, Integer source, String beginStartTime, String beginEndTime, Long userId, Integer type, String affiliationOrganization, String evcsOrderNo, String plateNum, Integer internetId, String internetSerialNumber, String terminalName, String vinCode, String overStartTime, String overEndTime, Long personnelId, Integer confirmResult); + + void export(HttpServletResponse response, String tenantId, Long chargingStationId, Long chargingPileId, Long terminalId, String phone, String transactionNumber, Integer status, String chargingStationName, Long operatorId, Integer source, String beginStartTime, String beginEndTime, Long userId, Integer type, String affiliationOrganization, String evcsOrderNo, String plateNum, Integer internetId, String internetSerialNumber, String terminalName, String vinCode, String overStartTime, String overEndTime, Long personnelId, Integer confirmResult) throws IOException; + + R getById(Long placeholderOrderId); +} diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcPlaceholderOrderServiceImpl.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcPlaceholderOrderServiceImpl.java new file mode 100644 index 00000000..a688bb60 --- /dev/null +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcPlaceholderOrderServiceImpl.java @@ -0,0 +1,419 @@ +package com.xhpc.order.service.impl; + +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUnit; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.io.IoUtil; +import cn.hutool.poi.excel.BigExcelWriter; +import cn.hutool.poi.excel.ExcelUtil; +import com.xhpc.common.api.UserTypeService; +import com.xhpc.common.core.domain.R; +import com.xhpc.common.core.utils.SecurityUtils; +import com.xhpc.common.core.web.domain.AjaxResult; +import com.xhpc.common.domain.XhpcPlaceholderTime; +import com.xhpc.common.enums.StopReasonEnum; +import com.xhpc.common.security.service.TokenService; +import com.xhpc.common.util.UserTypeUtil; +import com.xhpc.order.domain.XhpcChargeOrder; +import com.xhpc.order.domain.XhpcPlaceholderOrder; +import com.xhpc.order.dto.XhpcPlaceholderTimeOrderDto; +import com.xhpc.order.mapper.XhpcPlaceholderOrderMapper; +import com.xhpc.order.service.IXhpcPlaceholderOrderService; +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.annotation.Resource; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.*; + +import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS; + +/** + * @author yuyang + * @Date 2025-05-06 10:07 + */ +@Service +public class XhpcPlaceholderOrderServiceImpl implements IXhpcPlaceholderOrderService { + + @Resource + XhpcPlaceholderOrderMapper xhpcPlaceholderOrderMapper; + @Autowired + private TokenService tokenService; + @Autowired + private UserTypeService userTypeService; + + @Override + public int insertXhpcPlaceholderOrder(XhpcPlaceholderOrder placeholderOrder) { + return xhpcPlaceholderOrderMapper.insertXhpcPlaceholderOrder(placeholderOrder); + } + + @Override + public void getTimingPriceTime() { + String gunkey = "placeholderOrder:*"; + Collection orderKeys = REDIS.keys(gunkey); + for (String okey : orderKeys) { + Map cacheGun = REDIS.getCacheMap(okey); + if (cacheGun != null) { + try { + if ("1".equals(cacheGun.get("status").toString())) { + //占位费订单结束且删除缓存 + String serialNumber = cacheGun.get("serialNumber").toString(); + //查询订单 + XhpcPlaceholderOrder xhpcPlaceholderOrder = xhpcPlaceholderOrderMapper.getXhpcPlaceholderOrderSerialNumber(serialNumber); + + if (xhpcPlaceholderOrder.getConfirmResult() == -2 || xhpcPlaceholderOrder.getConfirmResult() == -1) { + //删除占位费时间段收费表 + xhpcPlaceholderOrderMapper.deleteByPlaceholderOrderIdInt(xhpcPlaceholderOrder.getPlaceholderOrderId()); + //结算订单,查询该时间段价格 + DateTime endTime = DateUtil.parse(cacheGun.get("endTime").toString()); + DateTime startTime = DateUtil.parse(cacheGun.get("startTime").toString()); + + String start = DateUtil.formatTime(startTime); + String end = DateUtil.formatTime(endTime); + long betweenDay = DateUtil.between(endTime, startTime, DateUnit.DAY); + long between = DateUtil.between(endTime, startTime, DateUnit.MINUTE); + xhpcPlaceholderOrder.setEndTime(endTime); + xhpcPlaceholderOrder.setTotalTimeSpan((int) between); + BigDecimal totalMoney = new BigDecimal("0.0"); + int freeTime = (int) xhpcPlaceholderOrder.getFreeTime(); + if (freeTime - between > 0) { + between = 0L; + } else { + between = between - freeTime; + if (betweenDay > 0) { + List xhpcPlaceholderTimeOne = xhpcPlaceholderOrderMapper.getXhpcPlaceholderTime(start, "23:59:59", xhpcPlaceholderOrder.getPlaceholderId()); + for (int i = 0; i < xhpcPlaceholderTimeOne.size(); i++) { + XhpcPlaceholderTime xhpcPlaceholderTime = xhpcPlaceholderTimeOne.get(i); + BigDecimal price = xhpcPlaceholderTime.getPrice(); + String pattern = "HH:mm:ss"; + Long startOne = DateUtil.parse(start, pattern).getTime(); + Long endOne = DateUtil.parse("23:59:59", pattern).getTime(); + + String format1 = DateUtil.format(xhpcPlaceholderTime.getStartTime(), pattern); + String format2 = DateUtil.format(xhpcPlaceholderTime.getEndTime(), pattern); + + Long time1 = DateUtil.parse(format1, pattern).getTime(); + Long time2 = DateUtil.parse(format2, pattern).getTime(); + XhpcPlaceholderTimeOrderDto placeholderTimeOrderDto = new XhpcPlaceholderTimeOrderDto(); + if (startOne < time1) { + startOne = time1; + placeholderTimeOrderDto.setStartTime(xhpcPlaceholderTime.getStartTime()); + }else{ + placeholderTimeOrderDto.setStartTime(DateUtil.parse(start, pattern)); + } + if (endOne > time2) { + endOne = time2; + placeholderTimeOrderDto.setEndTime(xhpcPlaceholderTime.getEndTime()); + }else{ + placeholderTimeOrderDto.setEndTime(DateUtil.parse("23:59:59", pattern)); + } + long betweOne = (endOne - startOne) / 60000; + int i1 = (int) (betweOne); + + if (freeTime - i1 > 0) { + freeTime = freeTime - i1; + ; + i1 = 0; + } else { + i1 = i1 - freeTime; + freeTime = 0; + + } + + BigDecimal multiply = new BigDecimal(i1).multiply(price); + totalMoney = totalMoney.add(multiply); + + placeholderTimeOrderDto.setPlaceholderOrderId(xhpcPlaceholderOrder.getPlaceholderOrderId()); + placeholderTimeOrderDto.setPrice(price); + placeholderTimeOrderDto.setTotalMoney(multiply); + placeholderTimeOrderDto.setTotalTimeSpan(i1); + xhpcPlaceholderOrderMapper.insertXhpcPlaceholderTimeOrder(placeholderTimeOrderDto); + + } + + List xhpcPlaceholderTimeTwo = xhpcPlaceholderOrderMapper.getXhpcPlaceholderTime("00:00:00", end, xhpcPlaceholderOrder.getPlaceholderId()); + for (int i = 0; i < xhpcPlaceholderTimeTwo.size(); i++) { + XhpcPlaceholderTime xhpcPlaceholderTime = xhpcPlaceholderTimeOne.get(i); + BigDecimal price = xhpcPlaceholderTime.getPrice(); + String pattern = "HH:mm:ss"; + Long startOne = DateUtil.parse("00:00:00", pattern).getTime(); + Long endOne = DateUtil.parse(end, pattern).getTime(); + + String format1 = DateUtil.format(xhpcPlaceholderTime.getStartTime(), pattern); + String format2 = DateUtil.format(xhpcPlaceholderTime.getEndTime(), pattern); + + Long time1 = DateUtil.parse(format1, pattern).getTime(); + Long time2 = DateUtil.parse(format2, pattern).getTime(); + + XhpcPlaceholderTimeOrderDto placeholderTimeOrderDto = new XhpcPlaceholderTimeOrderDto(); + if (startOne < time1) { + startOne = time1; + placeholderTimeOrderDto.setStartTime(xhpcPlaceholderTime.getStartTime()); + }else{ + placeholderTimeOrderDto.setStartTime(DateUtil.parse("00:00:00", pattern)); + } + if (endOne > time2) { + endOne = time2; + placeholderTimeOrderDto.setEndTime(xhpcPlaceholderTime.getEndTime()); + }else{ + placeholderTimeOrderDto.setEndTime(DateUtil.parse(end, pattern)); + } + long betweOne = (endOne - startOne) / 60000; + int i1 = (int) (betweOne); + + if (freeTime - i1 > 0) { + freeTime = freeTime - i1; + ; + i1 = 0; + } else { + i1 = i1 - freeTime; + freeTime = 0; + } + BigDecimal multiply = new BigDecimal(i1).multiply(price); + totalMoney = totalMoney.add(multiply); + + + placeholderTimeOrderDto.setPlaceholderOrderId(xhpcPlaceholderOrder.getPlaceholderOrderId()); + placeholderTimeOrderDto.setPrice(price); + placeholderTimeOrderDto.setTotalMoney(multiply); + placeholderTimeOrderDto.setTotalTimeSpan(i1); + xhpcPlaceholderOrderMapper.insertXhpcPlaceholderTimeOrder(placeholderTimeOrderDto); + } + } else { + List xhpcPlaceholderTimeOne = xhpcPlaceholderOrderMapper.getXhpcPlaceholderTime(start, end, xhpcPlaceholderOrder.getPlaceholderId()); + for (int i = 0; i < xhpcPlaceholderTimeOne.size(); i++) { + XhpcPlaceholderTime xhpcPlaceholderTime = xhpcPlaceholderTimeOne.get(i); + BigDecimal price = xhpcPlaceholderTime.getPrice(); + String pattern = "HH:mm:ss"; + Long startOne = DateUtil.parse(start, pattern).getTime(); + Long endOne = DateUtil.parse(end, pattern).getTime(); + + String format1 = DateUtil.format(xhpcPlaceholderTime.getStartTime(), pattern); + String format2 = DateUtil.format(xhpcPlaceholderTime.getEndTime(), pattern); + + Long time1 = DateUtil.parse(format1, pattern).getTime(); + Long time2 = DateUtil.parse(format2, pattern).getTime(); + + XhpcPlaceholderTimeOrderDto placeholderTimeOrderDto = new XhpcPlaceholderTimeOrderDto(); + if (startOne < time1) { + startOne = time1; + placeholderTimeOrderDto.setStartTime(xhpcPlaceholderTime.getStartTime()); + }else{ + placeholderTimeOrderDto.setStartTime(DateUtil.parse(start, pattern)); + } + if (endOne > time2) { + endOne = time2; + placeholderTimeOrderDto.setEndTime(xhpcPlaceholderTime.getEndTime()); + }else{ + placeholderTimeOrderDto.setEndTime(DateUtil.parse(end, pattern)); + } + long betweOne = (endOne - startOne) / 60000; + int i1 = (int) (betweOne); + + if (freeTime - i1 > 0) { + freeTime = freeTime - i1; + ; + i1 = 0; + } else { + i1 = i1 - freeTime; + freeTime = 0; + } + BigDecimal multiply = new BigDecimal(i1).multiply(price); + totalMoney = totalMoney.add(multiply); + + placeholderTimeOrderDto.setPlaceholderOrderId(xhpcPlaceholderOrder.getPlaceholderOrderId()); + placeholderTimeOrderDto.setPrice(price); + placeholderTimeOrderDto.setTotalMoney(multiply); + placeholderTimeOrderDto.setTotalTimeSpan(i1); + xhpcPlaceholderOrderMapper.insertXhpcPlaceholderTimeOrder(placeholderTimeOrderDto); + } + } + } + + xhpcPlaceholderOrder.setTotalMoney(totalMoney); + if (new BigDecimal(0).compareTo(new BigDecimal(between)) == 1) { + xhpcPlaceholderOrder.setOvertimePrice(totalMoney.divide(new BigDecimal(between), 2, BigDecimal.ROUND_HALF_UP)); + } else { + xhpcPlaceholderOrder.setOvertimePrice(new BigDecimal("0.0")); + } + String orderKey = "notificationPlaceholderOrderInfo:" + xhpcPlaceholderOrder.getSerialNumber(); + Map cacheOrder = new HashMap<>(); + cacheOrder.put("OvertimeBillCode", xhpcPlaceholderOrder.getPlaceholderOrderNumber()); + cacheOrder.put("StartChargeSeq", xhpcPlaceholderOrder.getInternetSerialNumber()); + cacheOrder.put("OvertimeBillStatus", 3); + cacheOrder.put("ConnectorId", xhpcPlaceholderOrder.getTerminalNumber()); + cacheOrder.put("BillEquipment", 1); + cacheOrder.put("StartTime", cacheGun.get("startTime").toString()); + cacheOrder.put("EndTime", cacheGun.get("endTime").toString()); + cacheOrder.put("TotalTimeSpan", xhpcPlaceholderOrder.getTotalTimeSpan()); + cacheOrder.put("OvertimePrice", xhpcPlaceholderOrder.getOvertimePrice()); + cacheOrder.put("TotalMoney", xhpcPlaceholderOrder.getTotalMoney()); + + Map overtimeDetails = new HashMap<>(); + overtimeDetails.put("DetailStartTime", cacheGun.get("startTime").toString()); + overtimeDetails.put("DetailEndTime", cacheGun.get("endTime").toString()); + overtimeDetails.put("DetailMoney", xhpcPlaceholderOrder.getTotalMoney()); + overtimeDetails.put("OvertimePrice", xhpcPlaceholderOrder.getOvertimePrice()); + cacheOrder.put("OvertimeDetails", overtimeDetails); + REDIS.setCacheMap(orderKey, cacheOrder); + + xhpcPlaceholderOrderMapper.updateXhpcPlaceholderOrder(xhpcPlaceholderOrder); + REDIS.deleteObject(okey); + } else if (xhpcPlaceholderOrder.getConfirmResult() == 0) { + REDIS.deleteObject(okey); + } else if (xhpcPlaceholderOrder.getConfirmResult() == 1) { + REDIS.deleteObject(okey); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + + } + } + } + + @Override + public List> getListPage(String tenantId, Long chargingStationId, Long chargingPileId, Long terminalId, String phone, String transactionNumber, Integer status, String chargingStationName, Long operatorId, Integer source, String beginStartTime, String beginEndTime, Long userId, Integer type, String affiliationOrganization, String evcsOrderNo, String plateNum, Integer internetId, String internetSerialNumber, String terminalName, String vinCode, String overStartTime, String overEndTime, Long personnelId, Integer confirmResult) { + Integer number = 0; + //电话和用户类型都不为null number =3 + //电话不为null,用户类型为null number =1 + //电话为null,用户类型不为null number=2 + //电话为null,用户类型为null number=0 + if (!"".equals(phone) && phone != null && !"".equals(source) && source != null) { + number = 3; + } else if (!"".equals(phone) && phone != null && source == null) { + number = 1; + } else if (phone == null && source != null) { + number = 2; + } + //获取登陆用户 + Long logUserId = SecurityUtils.getUserId(); + LoginUser loginUser = tokenService.getLoginUser(); + SysUser sysUser = loginUser.getSysUser(); + //桩的统计、该时段金额 + List> list = new ArrayList<>(); + if (!UserTypeUtil.SYS_USER_TYPE_ADMIN.equals(sysUser.getUserId())) { + if (UserTypeUtil.SYS_SUPER_TYPE_ONE.equals(loginUser.getSuperType())) { + tenantId = loginUser.getTenantId(); + Long logOperatorId = sysUser.getOperatorId(); + list = xhpcPlaceholderOrderMapper.getListPage(chargingStationId, chargingPileId, terminalId, phone, transactionNumber, 1, chargingStationName, operatorId, source, beginStartTime, beginEndTime, logOperatorId, type, number, affiliationOrganization, evcsOrderNo, plateNum, internetId, internetSerialNumber, terminalName, vinCode, overStartTime, overEndTime, personnelId, confirmResult, tenantId, 0); + } + if (UserTypeUtil.SYS_USER_TYPE_ONE.equals(sysUser.getUserType())) { + Long logOperatorId = sysUser.getOperatorId(); + //运营商看自己的场站 + list = xhpcPlaceholderOrderMapper.getListPage(chargingStationId, chargingPileId, terminalId, phone, transactionNumber, 1, chargingStationName, operatorId, source, beginStartTime, beginEndTime, logOperatorId, type, number, affiliationOrganization, evcsOrderNo, plateNum, internetId, internetSerialNumber, terminalName, vinCode, overStartTime, overEndTime, personnelId, confirmResult, tenantId, 0); + } else { + list = xhpcPlaceholderOrderMapper.getListPage(chargingStationId, chargingPileId, terminalId, phone, transactionNumber, 2, chargingStationName, operatorId, source, beginStartTime, beginEndTime, logUserId, type, number, affiliationOrganization, evcsOrderNo, plateNum, internetId, internetSerialNumber, terminalName, vinCode, overStartTime, overEndTime, personnelId, confirmResult, tenantId, 0); + } + } else { + list = xhpcPlaceholderOrderMapper.getListPage(chargingStationId, chargingPileId, terminalId, phone, transactionNumber, 0, chargingStationName, operatorId, source, beginStartTime, beginEndTime, userId, type, number, affiliationOrganization, evcsOrderNo, plateNum, internetId, internetSerialNumber, terminalName, vinCode, overStartTime, overEndTime, personnelId, confirmResult, tenantId, 0); + + } + return list; + } + + @Override + public void export(HttpServletResponse response, String tenantId, Long chargingStationId, Long chargingPileId, Long terminalId, String phone, String transactionNumber, Integer status, String chargingStationName, Long operatorId, Integer source, String beginStartTime, String beginEndTime, Long userId, Integer type, String affiliationOrganization, String evcsOrderNo, String plateNum, Integer internetId, String internetSerialNumber, String terminalName, String vinCode, String overStartTime, String overEndTime, Long personnelId, Integer confirmResult) throws IOException { + + Integer number = 0; + //电话和用户类型都不为null number =3 + //电话不为null,用户类型为null number =1 + //电话为null,用户类型不为null number=2 + //电话为null,用户类型为null number=0 + if (!"".equals(phone) && phone != null && !"".equals(source) && source != null) { + number = 3; + } else if (!"".equals(phone) && phone != null && source == null) { + number = 1; + } else if (phone == null && source != null) { + number = 2; + } + //获取登陆用户 + Long logUserId = SecurityUtils.getUserId(); + LoginUser loginUser = tokenService.getLoginUser(); + SysUser sysUser = loginUser.getSysUser(); + //桩的统计、该时段金额 + List> list = new ArrayList<>(); + if (!UserTypeUtil.SYS_USER_TYPE_ADMIN.equals(sysUser.getUserId())) { + if (UserTypeUtil.SYS_SUPER_TYPE_ONE.equals(loginUser.getSuperType())) { + tenantId = loginUser.getTenantId(); + Long logOperatorId = sysUser.getOperatorId(); + list = xhpcPlaceholderOrderMapper.getListPage(chargingStationId, chargingPileId, terminalId, phone, transactionNumber, 1, chargingStationName, operatorId, source, beginStartTime, beginEndTime, logOperatorId, type, number, affiliationOrganization, evcsOrderNo, plateNum, internetId, internetSerialNumber, terminalName, vinCode, overStartTime, overEndTime, personnelId, confirmResult, tenantId, 0); + } + if (UserTypeUtil.SYS_USER_TYPE_ONE.equals(sysUser.getUserType())) { + Long logOperatorId = sysUser.getOperatorId(); + //运营商看自己的场站 + list = xhpcPlaceholderOrderMapper.getListPage(chargingStationId, chargingPileId, terminalId, phone, transactionNumber, 1, chargingStationName, operatorId, source, beginStartTime, beginEndTime, logOperatorId, type, number, affiliationOrganization, evcsOrderNo, plateNum, internetId, internetSerialNumber, terminalName, vinCode, overStartTime, overEndTime, personnelId, confirmResult, tenantId, 0); + } else { + list = xhpcPlaceholderOrderMapper.getListPage(chargingStationId, chargingPileId, terminalId, phone, transactionNumber, 2, chargingStationName, operatorId, source, beginStartTime, beginEndTime, logUserId, type, number, affiliationOrganization, evcsOrderNo, plateNum, internetId, internetSerialNumber, terminalName, vinCode, overStartTime, overEndTime, personnelId, confirmResult, tenantId, 0); + } + } else { + list = xhpcPlaceholderOrderMapper.getListPage(chargingStationId, chargingPileId, terminalId, phone, transactionNumber, 0, chargingStationName, operatorId, source, beginStartTime, beginEndTime, userId, type, number, affiliationOrganization, evcsOrderNo, plateNum, internetId, internetSerialNumber, terminalName, vinCode, overStartTime, overEndTime, personnelId, confirmResult, tenantId, 0); + } + + // 通过工具类创建writer,默认创建xls格式 + BigExcelWriter writer = ExcelUtil.getBigWriter("placeholderOrder_" + System.currentTimeMillis() + ".xlsx"); + writer.addHeaderAlias("placeholderOrderId", "占位费订单ID"); + writer.addHeaderAlias("serialNumber", "充电订单号"); + writer.addHeaderAlias("internetSerialNumber", "流量方订单号"); + writer.addHeaderAlias("placeholderOrderNumber", "占位费订单号"); + writer.addHeaderAlias("chargingStationName", "电站名称"); + writer.addHeaderAlias("pileSerialNumber", "桩编号"); + writer.addHeaderAlias("terminalName", "终端名称"); +// writer.addHeaderAlias("operatorId", "运营商ID"); + writer.addHeaderAlias("operatorName", "运营商名称"); + writer.addHeaderAlias("freeTime", "免费时长(分钟)"); + writer.addHeaderAlias("maxFee", "最大占位费(元)"); + writer.addHeaderAlias("totalTimeSpan", "占位总时长(分钟)"); + writer.addHeaderAlias("totalMoney", "占位总费用(元)"); + writer.addHeaderAlias("startTime", "开始占位时间"); + writer.addHeaderAlias("endTime", "结束占位时间"); + writer.addHeaderAlias("chargingModeName", "订单来源"); + writer.addHeaderAlias("sourceName", "用户类型"); + writer.addHeaderAlias("confirmResultName", "推送状态"); +// writer.addHeaderAlias("plateNum", "电站名称"); +// writer.addHeaderAlias("disputeOrderStatus", "桩编号"); + + // 默认的,未添加alias的属性也会写出,如果想只写出加了别名的字段,可以调用此方法排除之 + writer.setOnlyAlias(true); + // 一次性写出内容,使用默认样式,强制输出标题 + writer.write(list, true); + //out为OutputStream,需要写出到的目标流 + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setCharacterEncoding("utf-8"); +// //response为HttpServletResponse对象 +// response.setContentType("application/vnd.ms-excel;charset=utf-8"); +// //test.xls是弹出下载对话框的文件名,不能为中文,中文请自行编码 +// response.setHeader("Content-Disposition", "attachment;filename=历史订单列表.xls"); + ServletOutputStream out = response.getOutputStream(); + + writer.flush(out, true); + // 关闭writer,释放内存 + writer.close(); + //此处记得关闭输出Servlet流 + IoUtil.close(out); + } + + @Override + public R getById(Long placeholderOrderId) { + try { + Map byId = xhpcPlaceholderOrderMapper.getById(placeholderOrderId); + if (byId != null) { + List> xhpcPlaceholderTimeOrder = xhpcPlaceholderOrderMapper.getXhpcPlaceholderTimeOrder(placeholderOrderId); + + byId.put("xhpcPlaceholderTimeOrder",xhpcPlaceholderTimeOrder); + } + return R.ok(byId); + } catch (Exception e) { + e.printStackTrace(); + return R.fail(e.getMessage()); + } + } + + +} 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 6c51cd69..35c8ab1b 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 @@ -28,6 +28,7 @@ import com.xhpc.order.dto.*; import com.xhpc.order.mapper.XhpcRealTimeOrderMapper; import com.xhpc.order.service.IXhpcChargeOrderService; import com.xhpc.order.service.IXhpcHistoryOrderService; +import com.xhpc.order.service.IXhpcPlaceholderOrderService; import com.xhpc.order.service.IXhpcRealTimeOrderService; import com.xhpc.system.api.domain.SysUser; import com.xhpc.system.api.model.LoginUser; @@ -82,6 +83,9 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe @Autowired private ActivityInternetService activityInternetService; + @Autowired + private IXhpcPlaceholderOrderService placeholderOrderService; + @Autowired private EvcsService evcsService; @@ -1604,6 +1608,8 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe if(xhpcPlaceholderMap !=null){ //占位订单生成 XhpcPlaceholderOrder placeholderOrder = new XhpcPlaceholderOrder(); + placeholderOrder.setChargingMode(xhpcHistoryOrder.getChargingMode()); + placeholderOrder.setDriverId(xhpcChargeOrder.getDriverId()); placeholderOrder.setHistoryOrderId(xhpcHistoryOrder.getHistoryOrderId()); placeholderOrder.setChargingStationId(xhpcHistoryOrder.getChargingStationId()); placeholderOrder.setChargeOrderId(xhpcHistoryOrder.getChargeOrderId()); @@ -1611,7 +1617,7 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe placeholderOrder.setUserId(xhpcHistoryOrder.getUserId()); placeholderOrder.setSerialNumber(xhpcHistoryOrder.getSerialNumber()); placeholderOrder.setInternetSerialNumber(xhpcHistoryOrder.getInternetSerialNumber()); - placeholderOrder.setConfirmResult(-1); + placeholderOrder.setConfirmResult(-2); placeholderOrder.setSource(xhpcHistoryOrder.getSource()); placeholderOrder.setPlaceholderId(Long.valueOf(xhpcPlaceholderMap.get("placeholderId").toString())); placeholderOrder.setFreeTime(Integer.valueOf(xhpcPlaceholderMap.get("freeTime").toString())); @@ -1627,7 +1633,7 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe placeholderOrder.setStartTime(xhpcHistoryOrder.getEndTime()); placeholderOrder.setCreateTime(new Date()); placeholderOrder.setTenantId(xhpcHistoryOrder.getTenantId()); - xhpcRealTimeOrderMapper.insertXhpcPlaceholderOrder(placeholderOrder); + placeholderOrderService.insertXhpcPlaceholderOrder(placeholderOrder); logger.info("<<<<<<<<<<<<<>>>>>>>>>>>>>>>"+placeholderOrder.getPlaceholderOrderId()); String gunkey = "placeholderOrder:"+substring+":"+xhpcHistoryOrder.getSerialNumber(); Map cacheGun =new HashMap<>(); @@ -1636,6 +1642,7 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe cacheGun.put("status",0); cacheGun.put("serialNumber",xhpcHistoryOrder.getSerialNumber()); cacheGun.put("internetSerialNumber",xhpcHistoryOrder.getInternetSerialNumber()); + cacheGun.put("startTime",DateUtil.format(xhpcHistoryOrder.getEndTime(),"yyyy-MM-dd HH:mm:ss")); REDIS.setCacheMap(gunkey, cacheGun); } }catch (Exception e){ diff --git a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcPlaceholderOrderMapper.xml b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcPlaceholderOrderMapper.xml new file mode 100644 index 00000000..9192ffdb --- /dev/null +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcPlaceholderOrderMapper.xml @@ -0,0 +1,637 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + insert into xhpc_placeholder_order + + + history_order_id, + + + charging_station_id, + + + charge_order_id, + + + user_id, + + + terminal_id, + + + serial_number, + + + internet_serial_number, + + + confirm_Result, + + + source, + + + placeholder_id, + + + free_time, + + + max_fee, + + + operator_id, + + + placeholder_order_number, + + + status, + + + terminal_number, + + + bill_equipment, + + + start_time, + + + end_time, + + + total_time_span, + + + overtime_price, + + + total_money, + + + price, + + + create_time, + + + create_by, + + + update_time, + + + update_by, + + + remark, + + + tenant_id, + + + charging_mode, + + + driver_id, + + + plate_num, + + + + + #{historyOrderId}, + + + #{chargingStationId}, + + + #{chargeOrderId}, + + + #{userId}, + + + #{terminalId}, + + + #{serialNumber}, + + + #{internetSerialNumber}, + + + #{confirmResult}, + + + #{source}, + + + #{placeholderId}, + + + #{freeTime}, + + + #{maxFee}, + + + #{operatorId}, + + + #{placeholderOrderNumber}, + + + #{status}, + + + #{terminalNumber}, + + + #{billEquipment}, + + + #{startTime}, + + + #{endTime}, + + + #{totalTimeSpan}, + + + #{overtimePrice}, + + + #{totalMoney}, + + + #{price}, + + + #{createTime}, + + + #{createBy}, + + + #{updateTime}, + + + #{updateBy}, + + + #{remark}, + + + #{tenantId}, + + + #{chargingMode}, + + + #{driverId}, + + + #{plateNum}, + + + + + + + + + + UPDATE xhpc_placeholder_order + + + start_time = #{startTime}, + + + end_time = #{endTime}, + + + total_time_span = #{totalTimeSpan}, + + + overtime_price = #{overtimePrice}, + + + total_money = #{totalMoney}, + + + where placeholder_order_id = #{placeholderOrderId} + + + + + + + + + + delete from xhpc_placeholder_time_order where placeholder_order_id =#{placeholderOrderId} + + + + + + insert into xhpc_placeholder_time_order + + + placeholder_time_order_id, + + + placeholder_order_id, + + + start_time, + + + end_time, + + + total_time_span, + + + total_money, + + + price, + + + create_time, + + + create_by, + + + update_time, + + + update_by, + + + remark, + + + tenant_id, + + + + + #{placeholderTimeOrderId}, + + + #{placeholderOrderId}, + + + #{startTime}, + + + #{endTime}, + + + #{totalTimeSpan}, + + + #{totalMoney}, + + + #{price}, + + + #{createTime}, + + + #{createBy}, + + + #{updateTime}, + + + #{updateBy}, + + + #{remark}, + + + #{tenantId}, + + + #{chargingMode}, + + + #{driverId}, + + + + 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 17398b5a..a4f85116 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcRealTimeOrderMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcRealTimeOrderMapper.xml @@ -1315,189 +1315,8 @@ max_fee as maxFee, free_time as freeTime, placeholder_id as placeholderId - from xhpc_placeholder where del_flag =0 and status =1 and NOW() >= start_time AND NOW() <= end_time + from xhpc_placeholder where del_flag =0 and status =1 and NOW() >= start_time AND NOW() <= end_time and charging_station_id =#{chargingStationId} - - insert into xhpc_placeholder_order - - - history_order_id, - - - charging_station_id, - - - charge_order_id, - - - user_id, - - - terminal_id, - - - serial_number, - - - internet_serial_number, - - - confirm_Result, - - - source, - - - placeholder_id, - - - free_time, - - - max_fee, - - - operator_id, - - - placeholder_order_number, - - - status, - - - terminal_number, - - - bill_equipment, - - - start_time, - - - end_time, - - - total_time_span, - - - overtime_price, - - - total_money, - - - price, - - - create_time, - - - create_by, - - - update_time, - - - update_by, - - - remark, - - - tenant_id, - - - - - #{historyOrderId}, - - - #{chargingStationId}, - - - #{chargeOrderId}, - - - #{userId}, - - - #{terminalId}, - - - #{serialNumber}, - - - #{internetSerialNumber}, - - - #{confirmResult}, - - - #{source}, - - - #{placeholderId}, - - - #{freeTime}, - - - #{maxFee}, - - - #{operatorId}, - - - #{placeholderOrderNumber}, - - - #{status}, - - - #{terminalNumber}, - - - #{billEquipment}, - - - #{startTime}, - - - #{endTime}, - - - #{totalTimeSpan}, - - - #{overtimePrice}, - - - #{totalMoney}, - - - #{price}, - - - #{createTime}, - - - #{createBy}, - - - #{updateTime}, - - - #{updateBy}, - - - #{remark}, - - - #{tenantId}, - - - + diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RealtimeDataLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RealtimeDataLogic.java index b524646b..f789124b 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RealtimeDataLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RealtimeDataLogic.java @@ -304,10 +304,11 @@ public class RealtimeDataLogic implements ServiceLogic { Collection orderKeys = REDIS.keys(gunkey); for (String okey : orderKeys) { - Map cacheGun = REDIS.getCacheMap(gunkey); - if(cacheGun !=null){ + Map cacheGun = REDIS.getCacheMap(okey); + if(cacheGun !=null && "0".equals(cacheGun.get("status").toString())){ cacheGun.put("status",1); - REDIS.setCacheMap(gunkey, cacheGun); + cacheGun.put("endTime",DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss")); + REDIS.setCacheMap(okey, cacheGun); } } }