From d86ddb98a3f8c7953810190ecc2df2a70a8c30c6 Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期六, 02 十一月 2024 20:22:11 +0800
Subject: [PATCH] bug修改
---
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java | 720 ++++++++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 609 insertions(+), 111 deletions(-)
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java
index a9d993a..4a14d46 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java
@@ -1,12 +1,10 @@
package com.ruoyi.order.controller;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.google.common.collect.Lists;
import java.math.BigDecimal;
import java.math.RoundingMode;
-import java.time.DayOfWeek;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
+import java.text.DecimalFormat;
+import java.time.*;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -21,29 +19,27 @@
import com.ruoyi.chargingPile.api.model.Site;
import com.ruoyi.chargingPile.api.model.TChargingGun;
import com.ruoyi.chargingPile.api.model.TChargingPile;
-import com.ruoyi.chargingPile.api.model.TParkingRecord;
-import com.ruoyi.chargingPile.api.vo.SiteVO;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.dto.ChargingOrderGroup;
import com.ruoyi.common.core.dto.ChargingPercentProvinceDto;
-import com.ruoyi.common.core.utils.DateUtils;
+import com.ruoyi.common.core.web.domain.BasePojo;
import com.ruoyi.common.redis.service.RedisService;
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.common.core.web.domain.AjaxResult;
-import com.ruoyi.common.core.web.page.BasePage;
import com.ruoyi.common.core.web.page.PageInfo;
+import com.ruoyi.integration.api.model.PageChargingOrderAndUploadRealTimeMonitoringDataDto;
import com.ruoyi.integration.api.model.UploadRealTimeMonitoringData;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.integration.api.feignClient.UploadRealTimeMonitoringDataClient;
import com.ruoyi.integration.api.model.ChargingOrderAndUploadRealTimeMonitoringDataDto;
-import com.ruoyi.integration.api.model.UploadRealTimeMonitoringData;
+import com.ruoyi.integration.api.model.UploadRealTimeMonitoringPageData;
import com.ruoyi.order.api.model.*;
import com.ruoyi.order.api.query.ChargingOrderQuery;
+import com.ruoyi.common.core.dto.MongoChargingOrderQuery;
import com.ruoyi.order.api.query.TChargingCountQuery;
import com.ruoyi.order.api.query.UploadRealTimeMonitoringDataQuery;
import com.ruoyi.order.api.vo.*;
import com.ruoyi.order.api.vo.ChargingOrderInfoVO;
-import com.ruoyi.order.api.vo.ChargingOrderVO;
import com.ruoyi.order.api.vo.GetChargingOrderByLicensePlate;
import com.ruoyi.order.api.vo.TCharingOrderVO;
import com.ruoyi.order.dto.GetMyChargingOrderList;
@@ -54,29 +50,26 @@
import com.ruoyi.order.dto.*;
import com.ruoyi.order.service.*;
import com.ruoyi.order.util.PreviousSixMonths;
+import com.ruoyi.order.vo.EndOfChargePageInfo;
import com.ruoyi.payment.api.feignClient.AliPaymentClient;
import com.ruoyi.payment.api.feignClient.WxPaymentClient;
import com.ruoyi.payment.api.vo.AliQueryOrder;
-import com.ruoyi.payment.api.vo.WxRefundNotifyResp;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
-import jdk.nashorn.internal.runtime.ListAdapter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
-import javax.servlet.ServletInputStream;
-import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
-import java.time.YearMonth;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalAdjusters;
-import java.util.*;
import java.util.*;
import java.util.List;
import java.util.stream.Collectors;
@@ -93,6 +86,8 @@
@RestController
@RequestMapping("/t-charging-order")
public class TChargingOrderController {
+
+ private Logger log = LoggerFactory.getLogger(TChargingOrderController.class);
@Resource
private TChargingOrderService chargingOrderService;
@@ -100,7 +95,8 @@
private TokenService tokenService;
@Autowired
private TOrderEvaluateService orderEvaluateService;
-
+ @Autowired
+ private TGrantVipService tGrantVipService;
@Resource
private WxPaymentClient wxPaymentClient;
@@ -137,10 +133,41 @@
private AppUserCarClient appUserCarClient;
@Resource
private TChargingOrderAccountingStrategyService chargingOrderAccountingStrategyService;
+
+ @Resource
+ private TOrderInvoiceService invoiceService;
+ /**
+ * 远程调用 增加管理后台赠送会员记录
+ * @return
+ */
+ @ResponseBody
+ @PostMapping(value = "/management/give/vip")
+ public R managementGiveVip(@RequestBody TGrantVip grantVip) {
+ return R.ok(tGrantVipService.save(grantVip));
+ }
-
-
+ /**
+ * 远程调用根据枪id 查询最新的订单id 用户后台结束充电
+ * @param id
+ * @return
+ */
+ @ResponseBody
+ @PostMapping(value = "/queryOrderByGunId/{id}")
+ public R<String> queryOrderByGunId(@PathVariable("id") String id) {
+ List<Integer> integers = new ArrayList<>();
+ integers.add(2);
+ integers.add(3);
+ integers.add(4);
+ TChargingOrder one = chargingOrderService.lambdaQuery()
+ .eq(TChargingOrder::getChargingGunId, id)
+ .in(TChargingOrder::getStatus, integers)
+ .one();
+ if (one!=null){
+ return R.ok(one.getId().toString());
+ }
+ return R.ok();
+ }
@ResponseBody
@PostMapping(value = "/pay/order/list")
@ApiOperation(value = "列表", tags = {"管理后台-支付订单-订单信息"})
@@ -167,8 +194,10 @@
payOrderInfoDto.setTradeNo(byId.getRechargeSerialNumber());
payOrderInfoDto.setPayType(byId.getRechargePaymentType());
payOrderInfoDto.setPayAmount(byId.getPaymentAmount());
- payOrderInfoDto.setPayTime(byId.getPayTime());
+ payOrderInfoDto.setPayTime(byId.getCreateTime());
payOrderInfoDto.setRefundAmount(byId.getRefundAmount());
+ payOrderInfoDto.setRechargeAmount(byId.getRechargeAmount());
+ payOrderInfoDto.setFinalAmount(byId.getRechargeAmount().subtract(byId.getRefundAmount()));
return R.ok(payOrderInfoDto);
case 2:
TShoppingOrder byId1 = shoppingOrderService.getById(orderId);
@@ -178,8 +207,10 @@
payOrderInfoDto1.setTradeNo(byId1.getSerialNumber());
payOrderInfoDto1.setPayType(byId1.getPaymentType());
payOrderInfoDto1.setPayAmount(byId1.getPaymentAmount());
- payOrderInfoDto1.setPayTime(byId1.getPayTime());
+ payOrderInfoDto1.setPayTime(byId1.getCreateTime());
payOrderInfoDto1.setRefundAmount(byId1.getRefundAmount());
+ payOrderInfoDto1.setRechargeAmount(byId1.getPaymentAmount());
+ payOrderInfoDto1.setFinalAmount(byId1.getPaymentAmount().subtract(byId1.getRefundAmount()));
return R.ok(payOrderInfoDto1);
case 3:
TVipOrder byId2 = vipOrderService.getById(orderId);
@@ -189,8 +220,10 @@
payOrderInfoDto2.setTradeNo(byId2.getSerialNumber());
payOrderInfoDto2.setPayType(byId2.getPaymentType());
payOrderInfoDto2.setPayAmount(byId2.getPaymentAmount());
- payOrderInfoDto2.setPayTime(byId2.getPayTime());
+ payOrderInfoDto2.setPayTime(byId2.getCreateTime());
payOrderInfoDto2.setRefundAmount(byId2.getRefundAmount());
+ payOrderInfoDto2.setRechargeAmount(byId2.getPaymentAmount());
+ payOrderInfoDto2.setFinalAmount(byId2.getPaymentAmount().subtract(byId2.getRefundAmount()));
return R.ok(payOrderInfoDto2);
//todo luo 停车场订单
// case 4:
@@ -234,7 +267,7 @@
@ResponseBody
@GetMapping(value = "/pay/order/charging")
@ApiOperation(value = "充电信息", tags = {"管理后台-支付订单-订单信息"})
- public R refundDetail(Long orderId) {
+ public R<PayOrderChargingInfo> refundDetail(Long orderId) {
PayOrderChargingInfo payOrderChargingInfo = new PayOrderChargingInfo();
TChargingOrder byId = chargingOrderService.getById(orderId);
List<Site> data = siteClient.getSiteByIds(Collections.singletonList(byId.getSiteId())).getData();
@@ -247,7 +280,20 @@
List<TAppUserCar> data3 = appUserCarClient.getCarByIds(Collections.singletonList(byId.getAppUserCarId())).getData();
payOrderChargingInfo.setCarNum(data3.get(0).getLicensePlate());
}
- return R.ok();
+ payOrderChargingInfo.setTChargingOrder(byId);
+
+ Long count = chargingOrderAccountingStrategyService.lambdaQuery().eq(TChargingOrderAccountingStrategy::getChargingOrderId, orderId).count();
+ payOrderChargingInfo.setPeriodCount(count);
+ if (byId.getAppUserCarId()!=null) {
+ List<Long> carid = new ArrayList<>();
+ carid.add(byId.getAppUserCarId());
+ R<List<TAppUserCar>> carByIds = appUserCarClient.getCarByIds(carid);
+ payOrderChargingInfo.setCarNum(carByIds.getData().get(0).getLicensePlate());
+ }
+ payOrderChargingInfo.setStartTime(byId.getStartTime());
+ payOrderChargingInfo.setEndTime(byId.getEndTime());
+ payOrderChargingInfo.setTimeCount(payOrderChargingInfo.calculateDuration());
+ return R.ok(payOrderChargingInfo);
}
@ResponseBody
@@ -255,6 +301,14 @@
@ApiOperation(value = "充电明细", tags = {"管理后台-支付订单-订单信息"})
public R<List<TChargingOrderAccountingStrategy>> chargingDetail(Long orderId) {
List<TChargingOrderAccountingStrategy> list = chargingOrderAccountingStrategyService.lambdaQuery().eq(TChargingOrderAccountingStrategy::getChargingOrderId, orderId).orderByDesc(TChargingOrderAccountingStrategy::getStartTime).list();
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+ for (TChargingOrderAccountingStrategy tChargingOrderAccountingStrategy : list) {
+ String format = tChargingOrderAccountingStrategy.getCreateTime().format(formatter);
+ tChargingOrderAccountingStrategy.setStartTime(format+" "+tChargingOrderAccountingStrategy.getStartTime());
+ tChargingOrderAccountingStrategy.setEndTime(format+" "+tChargingOrderAccountingStrategy.getEndTime());
+ }
+
+
return R.ok(list);
}
@@ -264,7 +318,11 @@
@PostMapping(value = "/pay/order/refund/list")
@ApiOperation(value = "列表", tags = {"管理后台-支付订单-退款订单"})
public R<PageInfo<TChargingOrderRefund>> refundList(@RequestBody ChargingRefundDto chargingRefundDto) {
- return chargingOrderService.getRefundList(chargingRefundDto);
+ R<PageInfo<TChargingOrderRefund>> refundList = chargingOrderService.getRefundList(chargingRefundDto);
+ for (TChargingOrderRefund record : refundList.getData().getRecords()) {
+ record.setUid(record.getId().toString());
+ }
+ return refundList;
}
@ResponseBody
@@ -291,20 +349,43 @@
}
@ResponseBody
- @PostMapping(value = "/chargingOrderInfo")
+ @GetMapping(value = "/chargingOrderInfo")
@ApiOperation(value = "充电桩订单列表查看详情", tags = {"管理后台-订单管理"})
- public AjaxResult<ChargingOrderInfoVO> chargingOrderInfo(String orderId) {
+ public AjaxResult<ChargingOrderInfoVO> chargingOrderInfo(String strategyId) {
+ TChargingOrder byId = chargingOrderService.getById(strategyId);
ChargingOrderInfoVO chargingOrderInfoVO = new ChargingOrderInfoVO();
- chargingOrderInfoVO.setCdElectronic("");
- chargingOrderInfoVO.setCdVoltage("");
- chargingOrderInfoVO.setSurplus("");
- chargingOrderInfoVO.setTotalPower("");
- chargingOrderInfoVO.setLicensePlate("");
- chargingOrderInfoVO.setVehicleBrand("");
- chargingOrderInfoVO.setVehicleModel("");
- chargingOrderInfoVO.setVehicleUse("");
- List<TChargingOrderAccountingStrategy> tChargingOrderAccountingStrategies = new ArrayList<>();
- chargingOrderInfoVO.setList(tChargingOrderAccountingStrategies);
+ chargingOrderInfoVO.setCdElectronic(byId.getCurrent()!=null?byId.getCurrent().setScale(2, BigDecimal.ROUND_HALF_DOWN)+"":"");
+ chargingOrderInfoVO.setCdVoltage(byId.getVoltage()!=null?byId.getVoltage().setScale(2, BigDecimal.ROUND_HALF_DOWN)+"":"");
+ chargingOrderInfoVO.setSurplus(byId.getTotalElectricity()!=null?byId.getTotalElectricity().setScale(2, BigDecimal.ROUND_HALF_DOWN)+"":"");
+ chargingOrderInfoVO.setTotalPower(byId.getPower()!=null?byId.getPower().setScale(2, BigDecimal.ROUND_HALF_DOWN)+"":"");
+ if (byId.getAppUserCarId()!=null){
+ TAppUserCar data = appUserCarClient.getCarById(byId.getAppUserCarId()+"").getData();
+ if (data!=null){
+ chargingOrderInfoVO.setLicensePlate(data.getLicensePlate());
+ chargingOrderInfoVO.setVehicleBrand(data.getVehicleBrand());
+ chargingOrderInfoVO.setVehicleModel(data.getVehicleModel());
+ chargingOrderInfoVO.setVehicleUse(data.getVehicleUse());
+ }
+ }
+ // 时段总服务费
+ List<TChargingOrderAccountingStrategy> list = chargingOrderAccountingStrategyService.lambdaQuery().eq(TChargingOrderAccountingStrategy::getChargingOrderId, strategyId).orderByDesc(TChargingOrderAccountingStrategy::getStartTime).list();
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+ for (TChargingOrderAccountingStrategy tChargingOrderAccountingStrategy : list) {
+ String format = tChargingOrderAccountingStrategy.getCreateTime().format(formatter);
+ tChargingOrderAccountingStrategy.setStartTime(format+" "+tChargingOrderAccountingStrategy.getStartTime());
+ tChargingOrderAccountingStrategy.setEndTime(format+" "+tChargingOrderAccountingStrategy.getEndTime());
+ if (byId.getVipDiscountAmount()!=null && byId.getServiceCharge().compareTo(BigDecimal.ZERO) != 0){
+ BigDecimal multiply = byId.getVipDiscountAmount().divide(byId.getServiceCharge(), 2)
+ .multiply(tChargingOrderAccountingStrategy.getPeriodOriginalServicePrice());
+ tChargingOrderAccountingStrategy.setVipDiscount(multiply);
+ }
+ if (byId.getCouponDiscountAmount()!=null && byId.getServiceCharge().compareTo(BigDecimal.ZERO) != 0){
+ BigDecimal multiply = byId.getCouponDiscountAmount().divide(byId.getServiceCharge(), 2)
+ .multiply(tChargingOrderAccountingStrategy.getPeriodOriginalServicePrice());
+ tChargingOrderAccountingStrategy.setCouponDiscount(multiply);
+ }
+ }
+ chargingOrderInfoVO.setList(list);
return AjaxResult.success(chargingOrderInfoVO);
}
@@ -322,10 +403,10 @@
* @param
* @return
*/
- @GetMapping(value = "/getCar")
- public R<Long> getCar() {
+ @GetMapping(value = "/getCar/{id}")
+ public R<Long> getCar(@PathVariable("id")String id) {
List<TChargingOrder> list = chargingOrderService.list(new LambdaQueryWrapper<TChargingOrder>()
- .eq(TChargingOrder::getAppUserId, tokenService.getLoginUserApplet().getUserId())
+ .eq(TChargingOrder::getAppUserId, id)
.isNotNull(TChargingOrder::getAppUserCarId));
if (!list.isEmpty()){
// 最近使用的车辆id
@@ -435,9 +516,33 @@
@PostMapping(value = "/chargingOrderWXCallback")
public void chargingOrderWXCallback(@RequestParam("out_trade_no") String out_trade_no, @RequestParam("transaction_id") String transaction_id,
@RequestParam("attach") String attach) {
- AjaxResult ajaxResult = chargingOrderService.chargingOrderCallback(1, out_trade_no, transaction_id, attach);
+ chargingOrderService.chargingOrderCallback(1, out_trade_no, transaction_id, attach);
}
-
+
+
+ /**
+ * 修改安全检测数据
+ * @param securityDetection
+ */
+ @ResponseBody
+ @PostMapping(value = "/securityDetection")
+ public void securityDetection(@RequestBody SecurityDetectionVO securityDetection){
+ log.error("-------------------安全检测数据-------------------:" + securityDetection);
+ chargingOrderService.securityDetection(securityDetection);
+ }
+
+ /**
+ * 远程启动充电应答
+ * @param message
+ */
+ @ResponseBody
+ @PostMapping(value = "/startChargeSuccessfully")
+ public void startChargeSuccessfully(@RequestBody PlatformStartChargingReplyMessageVO message){
+ log.error("-------------------远程启动充电请求应答-------------------:" + message);
+ chargingOrderService.startChargeSuccessfully(message);
+ }
+
+
/**
* 支付宝支付成功后的回调
@@ -467,10 +572,10 @@
*/
@ResponseBody
@PostMapping(value = "/chargingOrderStartupFailureWxRefund")
- public void chargingOrderStartupFailureWxRefund(@RequestParam("out_trade_no") String out_refund_no,
- @RequestParam("out_trade_no") String refund_id,
- @RequestParam("out_trade_no") String tradeState,
- @RequestParam("out_trade_no") String success_time){
+ public void chargingOrderStartupFailureWxRefund(@RequestParam("out_refund_no") String out_refund_no,
+ @RequestParam("refund_id") String refund_id,
+ @RequestParam("tradeState") String tradeState,
+ @RequestParam("success_time") String success_time){
chargingOrderService.chargingOrderStartupFailureWxRefund(out_refund_no, refund_id, tradeState, success_time);
}
@@ -513,6 +618,31 @@
public AjaxResult stopCharging(@PathVariable String id) {
return chargingOrderService.stopCharging(id);
}
+
+
+ /**
+ * 停止充电应答处理逻辑
+ * @param platformStopChargingReply
+ */
+ @PostMapping("/terminateSuccessfulResponse")
+ public void terminateSuccessfulResponse(@RequestBody PlatformStopChargingReplyVO platformStopChargingReply){
+ log.error("-------------------远程停止充电请求应答-------------------:" + platformStopChargingReply);
+ chargingOrderService.terminateSuccessfulResponse(platformStopChargingReply);
+ }
+
+
+ /**
+ * 停止充电返回账单后计算费用
+ * @param vo
+ */
+ @PostMapping("/endChargeBillingCharge")
+ public void endChargeBillingCharge(@RequestBody TransactionRecordMessageVO vo){
+ log.error("-------------------停止充电返回账单后计算费用及修改业务状态-------------------:" + vo);
+ chargingOrderService.endChargeBillingCharge(vo);
+ }
+
+
+
@ResponseBody
@GetMapping(value = "/six/charge")
@@ -531,10 +661,36 @@
}
LocalDate sixBefore = PreviousSixMonths.get();
//通过siteIds进行sql查询统计
+ List<SixChargingDto> sixChargingDtos = generateLastSixMonths();
List<SixChargingDto> chargingDtos = chargingOrderService.charge(sixBefore, siteIds);
+ for (SixChargingDto sixChargingDto : sixChargingDtos) {
+ for (SixChargingDto chargingDto : chargingDtos) {
+ if (sixChargingDto.getMonth().equals(chargingDto.getMonth())){
+ BeanUtils.copyProperties(chargingDto,sixChargingDto);
+ }
+ }
- return R.ok(chargingDtos);
+ }
+ return R.ok(sixChargingDtos);
+
+ }
+
+
+ public static List<SixChargingDto> generateLastSixMonths() {
+ LocalDate today = LocalDate.now();
+ List<SixChargingDto> months = new ArrayList<>();
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM");
+
+ for (int i = 5; i >= 0; i--) {
+ LocalDate date = today.minusMonths(i);
+ String month = date.format(formatter);
+ SixChargingDto sixChargingDto = new SixChargingDto();
+ sixChargingDto.setMonth(month);
+ months.add(sixChargingDto);
+ }
+
+ return months;
}
@ResponseBody
@@ -568,7 +724,33 @@
//count近6个月的数据
LocalDate sixBefore = PreviousSixMonths.get();
List<SixShopDto> sixShopDtos = shoppingOrderService.sixBefore(sixBefore,status);
- return R.ok(sixShopDtos);
+ List<SixShopDto> sixChargingDtos = generateLastSixMonths1();
+ for (SixShopDto sixChargingDto : sixChargingDtos) {
+ for (SixShopDto chargingDto : sixShopDtos) {
+ if (sixChargingDto.getMonth().equals(chargingDto.getMonth())){
+ BeanUtils.copyProperties(chargingDto,sixChargingDto);
+ }
+ }
+
+ }
+
+ return R.ok(sixChargingDtos);
+ }
+
+ public static List<SixShopDto> generateLastSixMonths1() {
+ LocalDate today = LocalDate.now();
+ List<SixShopDto> months = new ArrayList<>();
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM");
+
+ for (int i = 5; i >= 0; i--) {
+ LocalDate date = today.minusMonths(i);
+ String month = date.format(formatter);
+ SixShopDto sixChargingDto = new SixShopDto();
+ sixChargingDto.setMonth(month);
+ months.add(sixChargingDto);
+ }
+
+ return months;
}
@ResponseBody
@@ -599,13 +781,18 @@
LocalDate sixBefore = PreviousSixMonths.get();
Map<String,Object> map = chargingOrderService.countAll(sixBefore);
BigDecimal data = parkingLotClient.getRecordAmount(sixBefore).getData();
+ if (map ==null){
+ map = new HashMap<String,Object>();
+ }
map.put("parkingAmount",data);
BigDecimal data1 = shoppingOrderService.getSumAmount(sixBefore);
map.put("shopAmount",data1);
BigDecimal data2 = vipOrderService.getSumAmout(sixBefore);
map.put("vipAmount",data2);
- return R.ok(map);
+
+
+ return R.ok(map);
}
@Resource
@@ -613,38 +800,63 @@
@ResponseBody
@PostMapping(value = "/watch/chargingOrder")
@ApiOperation(value = "监控订单", tags = {"管理后台-订单管理"})
- public R<List<ChargingOrderAndUploadRealTimeMonitoringDataDto>> watchChargingOrder(@RequestBody ChargingOrderQuery dto) {
- Integer page = dto.getPageCurr();
- Integer pageSize = dto.getPageSize();
- List<Long> data = appUserClient.getUserIdsByPhone(dto.getPhone()).getData();
- dto.setUserIds(data);
- dto.setPageCurr(1);
- dto.setPageSize(99999);
- TCharingOrderVO res = chargingOrderService.chargingOrder(dto);
- Map<String,TChargingOrder> map = new HashMap<>();
- //吧list放入map中
- for (ChargingOrderVO record : res.getList().getRecords()) {
- map.put(record.getCode(),record);
- }
- Set<String> strings = map.keySet();
+ public R watchChargingOrder(@RequestBody MongoChargingOrderQuery mongoChargingOrderQuery) {
-
- List<UploadRealTimeMonitoringData> data1 = uploadRealTimeMonitoringDataClient.getAll(strings, page, pageSize).getData();
+ mongoChargingOrderQuery.setPageSize(10);
+ R<UploadRealTimeMonitoringPageData> all = uploadRealTimeMonitoringDataClient.getAll(mongoChargingOrderQuery);
+ UploadRealTimeMonitoringPageData data1 = all.getData();
List<ChargingOrderAndUploadRealTimeMonitoringDataDto> dtos = new ArrayList<>();
- for (UploadRealTimeMonitoringData uploadRealTimeMonitoringData : data1) {
+ Map<String,ChargingOrderVO> map = new HashMap<>();
+ for (UploadRealTimeMonitoringData uploadRealTimeMonitoringData : data1.getRecords()) {
ChargingOrderAndUploadRealTimeMonitoringDataDto dataDto = new ChargingOrderAndUploadRealTimeMonitoringDataDto();
- BeanUtils.copyProperties(uploadRealTimeMonitoringData,dataDto);
- BeanUtils.copyProperties(map.get(uploadRealTimeMonitoringData.getCharging_pile_code()),dataDto);
- dtos.add(dataDto);
+ ChargingOrderQuery dto = new ChargingOrderQuery();
+ dto.setCode(uploadRealTimeMonitoringData.getTransaction_serial_number());
+
+ if (map.get(uploadRealTimeMonitoringData.getTransaction_serial_number())==null) {
+ TCharingOrderVO vo = chargingOrderService.chargingOrder(dto);
+ map.put(uploadRealTimeMonitoringData.getTransaction_serial_number(),vo.getList().getRecords().get(0));
+ if (!vo.getList().getRecords().isEmpty()) {
+ ChargingOrderVO chargingOrderVO = vo.getList().getRecords().get(0);
+ if (chargingOrderVO != null) {
+ BeanUtils.copyProperties(chargingOrderVO, dataDto);
+ }
+ BeanUtils.copyProperties(uploadRealTimeMonitoringData, dataDto);
+ dataDto.setStartTime(uploadRealTimeMonitoringData.getStartTime());
+ dataDto.setEndTime(uploadRealTimeMonitoringData.getEndTime() == null ? null : uploadRealTimeMonitoringData.getEndTime());
+ dataDto.setStatus(uploadRealTimeMonitoringData.getStatus());
+ dtos.add(dataDto);
+ }
+ }else {
+ ChargingOrderVO vo = map.get(uploadRealTimeMonitoringData.getTransaction_serial_number());
+ BeanUtils.copyProperties(vo, dataDto);
+ BeanUtils.copyProperties(uploadRealTimeMonitoringData, dataDto);
+ dataDto.setStartTime(uploadRealTimeMonitoringData.getStartTime());
+ dataDto.setEndTime(uploadRealTimeMonitoringData.getEndTime() == null ? null : uploadRealTimeMonitoringData.getEndTime());
+ dataDto.setStatus(uploadRealTimeMonitoringData.getStatus());
+ dtos.add(dataDto);
+ }
+ }
+ for (int i = 0; i < dtos.size(); i++) {
+ dtos.get(i).setIndex(i);
}
+ PageChargingOrderAndUploadRealTimeMonitoringDataDto page = new PageChargingOrderAndUploadRealTimeMonitoringDataDto();
+ page.setTotal(data1.getCount());
+ page.setRecords(dtos);
- return R.ok(dtos);
+ return R.ok(page);
}
-
-
-
+
+
+
+ @ResponseBody
+ @GetMapping(value = "/watch/deletes")
+ @ApiOperation(value = "监控订单-删除", tags = {"管理后台-订单管理"})
+ public R watchChargingOrder(@RequestParam String id) {
+ uploadRealTimeMonitoringDataClient.delete(id);
+ return R.ok();
+ }
/**
* 处理充电订单实时监控数据相关的业务逻辑
@@ -691,63 +903,211 @@
LocalDate end = null;
if (statisticsQueryDto.getDayType()==1){
start = LocalDate.now();
+ end = LocalDate.now().plusDays(1);
}else if (statisticsQueryDto.getDayType()==2){
LocalDate today = LocalDate.now();
// 获取本周一的日期
LocalDate mondayThisWeek = today.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
-
+ start = statisticsQueryDto.getStartTime();
+ end = statisticsQueryDto.getEndTime();
System.out.println("本周一是: " + mondayThisWeek);
}
else if (statisticsQueryDto.getDayType()==3){
// 获取当前日期
LocalDate today = LocalDate.now();
-
+ start = statisticsQueryDto.getStartTime();
+ end = statisticsQueryDto.getEndTime().plusDays(1);
// 获取本月1号的日期
- YearMonth yearMonth = YearMonth.from(today);
- start = yearMonth.atDay(1);
-
- System.out.println("本月1号是: " + start);
+// start = yearMonth.atDay(1);
+//
+// System.out.println("本月1号是: " + start);
}else if (statisticsQueryDto.getDayType()==4){
- LocalDate today = LocalDate.now();
- // 获取当前年份
- int currentYear = today.getYear();
+
// 获取今年1月1日的日期
- start = LocalDate.of(currentYear, 1, 1);
- System.out.println("今年1月1日是: " + start);
+ start = statisticsQueryDto.getStartTime();
+ end = statisticsQueryDto.getEndTime();
}else if (statisticsQueryDto.getDayType()==5){
// 获取今年1月1日的日期
start = statisticsQueryDto.getStartTime();
end = statisticsQueryDto.getEndTime();
+ if (start.equals(end)){
+ end = end.plusDays(1);
+ }
}
- List<TChargingOrder> list = chargingOrderService.lambdaQuery().ge(TChargingOrder::getStartTime, start).le(TChargingOrder::getEndTime, end).in(TChargingOrder::getSiteId, siteIds).list();
+
+ List<TChargingOrder> list = chargingOrderService.lambdaQuery().ge(TChargingOrder::getCreateTime, start).le(TChargingOrder::getCreateTime, end).in(TChargingOrder::getSiteId, siteIds).list();
List<Long> chargingOrderIds = list.stream().map(TChargingOrder::getId).collect(Collectors.toList());
+ chargingOrderIds.add(-1L);
//上方饼图
List<Map<String,Object>> maps = chargingOrderService.getSumByType(chargingOrderIds);
if (statisticsQueryDto.getDayType()==1){
List<Map<String,Object>> maps1 = chargingOrderService.getDateData(chargingOrderIds);
- tCharingOrderMapVO.setMaps1(maps1);
+
+ List<Map<String, Object>> charMap = new ArrayList<>();
+ // 生成从 "00:00" 到 "23:00" 的时间数据
+ for (int hour = 0; hour < 24; hour++) {
+ String time = String.format("%02d:00", hour);
+ Map<String, Object> mapWithTimeValue = findMapWithTimeValue(maps1, time);
+ if (mapWithTimeValue!=null){
+ charMap.add(mapWithTimeValue);
+ }else {
+ Map<String, Object> timeMap = new HashMap<>();
+ timeMap.put("time", time); // 初始化值为 null
+ timeMap.put("electrovalence", 0);
+ timeMap.put("orderCount", 0);
+ timeMap.put("paymentAmount", 0);
+ timeMap.put("paymoney", 0);
+ timeMap.put("servicecharge", 0);
+
+ charMap.add(timeMap);
+ }
+ }
+
+ tCharingOrderMapVO.setMaps1(charMap);
}else if (statisticsQueryDto.getDayType()==2){
+
+
+
List<Map<String,Object>> maps1 = chargingOrderService.getWeekData(chargingOrderIds);
- tCharingOrderMapVO.setMaps1(maps1);
+
+ LocalDate startDate = statisticsQueryDto.getStartTime();
+ LocalDate endDate = statisticsQueryDto.getEndTime();
+
+ List<Map<String, Object>> dateRangeStatistics = new ArrayList<>();
+
+ // 遍历日期范围
+ while (!startDate.isAfter(endDate)) {
+ String formattedDate = startDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+ Map<String, Object> dailyStats = findMapWithDateValue(maps1, formattedDate);
+
+ if (dailyStats != null) {
+ dateRangeStatistics.add(dailyStats);
+ } else {
+ Map<String, Object> dateMap = new HashMap<>();
+ dateMap.put("time", formattedDate);
+ dateMap.put("electrovalence", 0);
+ dateMap.put("orderCount", 0);
+ dateMap.put("paymentAmount", 0);
+ dateMap.put("paymoney", 0);
+ dateMap.put("servicecharge", 0);
+ dateRangeStatistics.add(dateMap);
+ }
+
+ // 移动到下一天
+ startDate = startDate.plusDays(1);
+ }
+ tCharingOrderMapVO.setMaps1(dateRangeStatistics);
}else if (statisticsQueryDto.getDayType()==3){
List<Map<String,Object>> maps1 = chargingOrderService.getMonthData(chargingOrderIds);
- tCharingOrderMapVO.setMaps1(maps1);
+
+ LocalDate startDate = statisticsQueryDto.getStartTime();
+ LocalDate endDate = statisticsQueryDto.getEndTime();
+
+ List<Map<String, Object>> dateRangeStatistics = new ArrayList<>();
+
+ // 遍历日期范围
+ while (!startDate.isAfter(endDate)) {
+ String formattedDate = startDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+ Map<String, Object> dailyStats = findMapWithDateValue(maps1, formattedDate);
+
+ if (dailyStats != null) {
+ dateRangeStatistics.add(dailyStats);
+ } else {
+ Map<String, Object> dateMap = new HashMap<>();
+ dateMap.put("time", formattedDate);
+ dateMap.put("electrovalence", 0);
+ dateMap.put("orderCount", 0);
+ dateMap.put("paymentAmount", 0);
+ dateMap.put("paymoney", 0);
+ dateMap.put("servicecharge", 0);
+ dateRangeStatistics.add(dateMap);
+ }
+
+ // 移动到下一天
+ startDate = startDate.plusDays(1);
+ }
+ tCharingOrderMapVO.setMaps1(dateRangeStatistics);
}else if (statisticsQueryDto.getDayType()==4){
List<Map<String,Object>> maps1 = chargingOrderService.getYearData(chargingOrderIds);
- tCharingOrderMapVO.setMaps1(maps1);
+
+ LocalDate startDate = statisticsQueryDto.getStartTime();
+ LocalDate endDate = statisticsQueryDto.getEndTime();
+
+
+ List<Map<String, Object>> dateRangeStatistics = new ArrayList<>();
+
+ // 遍历日期范围
+ while (!startDate.isAfter(endDate)) {
+ String formattedDate = startDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+ Map<String, Object> dailyStats = findMapWithDateValue(maps1, formattedDate);
+
+ if (dailyStats != null) {
+ dateRangeStatistics.add(dailyStats);
+ } else {
+ Map<String, Object> dateMap = new HashMap<>();
+ dateMap.put("time", formattedDate);
+ dateMap.put("electrovalence", 0);
+ dateMap.put("orderCount", 0);
+ dateMap.put("paymentAmount", 0);
+ dateMap.put("paymoney", 0);
+ dateMap.put("servicecharge", 0);
+ dateRangeStatistics.add(dateMap);
+ }
+
+ // 移动到下一天
+ startDate = startDate.plusDays(1);
+ }
+ tCharingOrderMapVO.setMaps1(dateRangeStatistics);
}else if (statisticsQueryDto.getDayType()==5){
List<Map<String,Object>> maps1 = chargingOrderService.getByDate(chargingOrderIds);
- tCharingOrderMapVO.setMaps1(maps1);
+
+ LocalDate startDate = statisticsQueryDto.getStartTime();
+ LocalDate endDate = statisticsQueryDto.getEndTime();
+
+
+
+ List<Map<String, Object>> dateRangeStatistics = new ArrayList<>();
+
+ // 遍历日期范围
+ while (!startDate.isAfter(endDate)) {
+ String formattedDate = startDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+ Map<String, Object> dailyStats = findMapWithDateValue(maps1, formattedDate);
+
+ if (dailyStats != null) {
+ dateRangeStatistics.add(dailyStats);
+ } else {
+ Map<String, Object> dateMap = new HashMap<>();
+ dateMap.put("time", formattedDate);
+ dateMap.put("electrovalence", 0);
+ dateMap.put("orderCount", 0);
+ dateMap.put("paymentAmount", 0);
+ dateMap.put("paymoney", 0);
+ dateMap.put("servicecharge", 0);
+ dateRangeStatistics.add(dateMap);
+ }
+
+ // 移动到下一天
+ startDate = startDate.plusDays(1);
+ }
+ tCharingOrderMapVO.setMaps1(dateRangeStatistics);
}
tCharingOrderMapVO.setMaps(maps);
+ BigDecimal allMoney = new BigDecimal(0);
+ for (Map<String, Object> map : maps) {
+ BigDecimal periodElectricPrice = (BigDecimal) map.get("period_electric_price");
+ allMoney = allMoney.add(periodElectricPrice);
+ BigDecimal total_amount = (BigDecimal) map.get("total_amount");
+ allMoney = allMoney.add(total_amount);
+ }
+ allMoney = allMoney.multiply(new BigDecimal("0.006"));
-
+ tCharingOrderMapVO.setAllMoney(allMoney);
return R.ok(tCharingOrderMapVO);
}
@@ -768,6 +1128,8 @@
} else {
siteIds.add(statisticsQueryDto.getSiteId());
}
+
+
List<Map<String,Object>> maps1 = chargingOrderService.queryPower(siteIds);
@@ -829,6 +1191,8 @@
tCharingUserMapVO.setMap(charMap);
tCharingUserMapVO.setMap1(charMap1);
}else {
+
+
List<Map<String,Object>> map = chargingOrderService.usersByQuery(statisticsQueryDto);
@@ -857,11 +1221,50 @@
startDate = startDate.plusDays(1);
}
- tCharingUserMapVO.setMap(map);
+ tCharingUserMapVO.setMap(dateRangeStatistics);
+
+
+ List<Map<String,Object>> map1 = chargingOrderService.usersByQuery1(statisticsQueryDto);
+
+
+
+ LocalDate startDate1 = statisticsQueryDto.getStartTime();
+ LocalDate endDate1 = statisticsQueryDto.getEndTime();
+
+ List<Map<String, Object>> dateRangeStatistics1 = new ArrayList<>();
+
+ // 遍历日期范围
+ while (!startDate1.isAfter(endDate1)) {
+ String formattedDate = startDate1.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+ Map<String, Object> dailyStats = findMapWithDateValue(map1, formattedDate);
+
+ if (dailyStats != null) {
+ dateRangeStatistics1.add(dailyStats);
+ } else {
+ Map<String, Object> dateMap = new HashMap<>();
+ dateMap.put("time", formattedDate);
+ dateMap.put("counts", 0);
+ dateRangeStatistics1.add(dateMap);
+ }
+
+ // 移动到下一天
+ startDate1 = startDate1.plusDays(1);
+ }
+
+ tCharingUserMapVO.setMap1(dateRangeStatistics1);
+
+
+
+
}
//用户标签
List<Map<String,Object>> maps = chargingOrderService.getUserTagCount();
+ Map<String,Object> stringObjectMap = new HashMap<>();
+ Long noTagCount = chargingOrderService.countNoTag();
+ stringObjectMap.put("count",noTagCount);
+ maps.add(stringObjectMap);
+
//会员标签
List<Map<String,Object>> maps1 = chargingOrderService.getVipCount();
@@ -870,8 +1273,19 @@
//车辆用途
List<Map<String, Object>> carMap = chargingOrderService.carUserMethod();
+
//车辆品牌
List<Map<String, Object>> carBrandMap = chargingOrderService.carUserBrand();
+ List<String> brands = new ArrayList<>();
+ for (Map<String, Object> objectMap : carBrandMap) {
+ brands.add(objectMap.get("vehicle_brand").toString());
+ }
+
+ Long count = chargingOrderService.countCar(brands);
+ Map<String, Object> others = new HashMap<>();
+ others.put("vehicle_brand","其他");
+ others.put("counts",count);
+ carBrandMap.add(others);
//本地车数量
Map<String,Object> localCarMap = chargingOrderService.countLocalCar();
@@ -901,11 +1315,14 @@
siteIds.add(statisticsQueryDto.getSiteId());
}
//查询评价分
- Long aver = chargingOrderService.getAver(siteIds);
+ Double aver = chargingOrderService.getAver(siteIds);
//查询各个分数
List<Map<String,Object>> evaluate = chargingOrderService.getLevelEvaluate(siteIds);
//查询差评回复数
- Long count = orderEvaluateService.lambdaQuery().isNotNull(TOrderEvaluate::getResponseTime).count();
+ List<Integer> mark = new ArrayList<>();
+ mark.add(1);
+ mark.add(2);
+ Long count = orderEvaluateService.lambdaQuery().in(TOrderEvaluate::getMark, mark).isNotNull(TOrderEvaluate::getResponseTime).count();
TCharingUserEvaluateVO tCharingUserEvaluateVO = new TCharingUserEvaluateVO();
tCharingUserEvaluateVO.setAver(aver);
tCharingUserEvaluateVO.setEvaluate(evaluate);
@@ -918,7 +1335,7 @@
List<Map<String,Object>> badTop = orderEvaluateService.badTop(siteIds);
//流量分析
- List<Map<String,Object>> sourceMap = chargingOrderService.countBySource(siteIds);
+ List<Map<String,Object>> sourceMap = chargingOrderService.countBySource(siteIds,statisticsQueryDto);
tCharingUserEvaluateVO.setGoodTop(goodTop);
tCharingUserEvaluateVO.setBadTop(badTop);
tCharingUserEvaluateVO.setFlow(sourceMap);
@@ -931,7 +1348,7 @@
@ApiOperation(value = "电站评价", tags = {"管理后台-数据分析-设备运维分析"})
public R<TCharingUserEquimentVO> equipment(@RequestBody ChargingStatisticsQueryDto statisticsQueryDto){
List<Integer> siteIds =new ArrayList<>();
- if (statisticsQueryDto.getSiteId()==null) {
+ if (statisticsQueryDto.getSiteId()==null||statisticsQueryDto.getSiteId()==0) {
Long userId = SecurityUtils.getUserId();
//获取当前登录的siteIds
List<GetSiteListDTO> data = siteClient.getSiteListByUserId(userId).getData();
@@ -943,8 +1360,48 @@
}
//直流可用率
List<Map<String,Object>> equipmentMap1 = chargingOrderService.equipmentUserType1(siteIds,statisticsQueryDto);
+ for (Map<String, Object> result : equipmentMap1) {
+ Object percentObj = result.get("percent");
+ if (percentObj instanceof String) {
+ try {
+ BigDecimal percent = new BigDecimal((String) percentObj);
+ if (percent.compareTo(BigDecimal.ZERO) < 0) {
+ result.put("percent", percent.negate().toString());
+ }
+ } catch (NumberFormatException e) {
+ // 处理转换异常
+ result.put("percent", BigDecimal.ZERO); // 或者其他默认值
+ }
+ } else if (percentObj instanceof BigDecimal) {
+ BigDecimal percent = (BigDecimal) percentObj;
+ if (percent.compareTo(BigDecimal.ZERO) < 0) {
+ result.put("percent", percent.negate().toString());
+ }
+ }
+ }
+
//交流可用率
List<Map<String,Object>> equipmentMap2= chargingOrderService.equipmentUserType2(siteIds,statisticsQueryDto);
+
+ for (Map<String, Object> result : equipmentMap2) {
+ Object percentObj = result.get("percent");
+ if (percentObj instanceof String) {
+ try {
+ BigDecimal percent = new BigDecimal((String) percentObj);
+ if (percent.compareTo(BigDecimal.ZERO) < 0) {
+ result.put("percent", percent.negate().toString());
+ }
+ } catch (NumberFormatException e) {
+ // 处理转换异常
+ result.put("percent", BigDecimal.ZERO); // 或者其他默认值
+ }
+ } else if (percentObj instanceof BigDecimal) {
+ BigDecimal percent = (BigDecimal) percentObj;
+ if (percent.compareTo(BigDecimal.ZERO) < 0) {
+ result.put("percent", percent.negate().toString());
+ }
+ }
+ }
//取出直流可用率和交流可用率的percent的平均值保留两位小数
@@ -993,8 +1450,8 @@
return R.ok(tCharingUserEquimentVO);
}
-
- private static double calculateAveragePercent(List<Map<String, Object>> mapList1, List<Map<String, Object>> mapList2) {
+ private static final DecimalFormat DF = new DecimalFormat("#.00");
+ public static double calculateAveragePercent(List<Map<String, Object>> mapList1, List<Map<String, Object>> mapList2) {
int totalElements = mapList1.size() + mapList2.size();
double sum = 0.0;
@@ -1016,7 +1473,10 @@
}
// 计算平均值
- return sum / totalElements;
+ double average = sum / totalElements;
+
+ // 格式化为两位小数
+ return Double.parseDouble(DF.format(average));
}
@ResponseBody
@@ -1034,11 +1494,19 @@
} else {
siteIds.add(statisticsQueryDto.getSiteId());
}
- List<TChargingOrder> list = chargingOrderService.lambdaQuery().in(!siteIds.isEmpty(), TChargingOrder::getSiteId, siteIds).eq(statisticsQueryDto.getSiteId() != null, TChargingOrder::getSiteId, statisticsQueryDto.getSiteId()).list();
+ LocalDateTime selectDate = statisticsQueryDto.getSelectDate();
+ LocalDateTime min = selectDate.with(LocalTime.MIN);
+ LocalDateTime max = selectDate.with(LocalTime.MAX);
+
+
+
+
+
+ List<TChargingOrder> list = chargingOrderService.lambdaQuery().in(!siteIds.isEmpty(), TChargingOrder::getSiteId, siteIds).ge( TChargingOrder::getCreateTime,min).le(BasePojo::getCreateTime,max).eq(TChargingOrder::getStatus,5).eq(statisticsQueryDto.getSiteId() != null, TChargingOrder::getSiteId, statisticsQueryDto.getSiteId()).list();
//当日的订单总数
int size = list.size();
//计算list中paymentAmount的总和
- BigDecimal totalPaymentAmount = list.stream().map(TChargingOrder::getOrderAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
+ BigDecimal totalPaymentAmount = list.stream().map(TChargingOrder::getPaymentAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
//计算list中electrovalence的总和
BigDecimal totalElectrovalence = list.stream().map(TChargingOrder::getElectrovalence).reduce(BigDecimal.ZERO, BigDecimal::add);
//计算list中serviceCharge的总和
@@ -1204,8 +1672,9 @@
//将capMap的chargingCapacity除以totalRatedPower保留两位数
capMap.forEach(map -> {
BigDecimal chargingCapacity = (BigDecimal) map.get("chargingCapacity");
- BigDecimal result = chargingCapacity.divide(totalRatedPower, 2, RoundingMode.HALF_UP);
- map.put("chargingCapacity", result);
+ BigDecimal result = chargingCapacity.divide(totalRatedPower, 4, RoundingMode.HALF_UP);
+ BigDecimal multiply = result.multiply(new BigDecimal(100));
+ map.put("chargingCapacity", multiply);
});
@@ -1239,8 +1708,7 @@
}
- @Resource
- private TOrderInvoiceService invoiceService;
+
@ResponseBody
@GetMapping(value = "/work/shopOrder")
@ApiOperation(value = "购物订单统计", tags = {"管理后台-工作台"})
@@ -1273,14 +1741,18 @@
return R.ok(userMap);
}
- public static void main(String[] args) {
- // 示例数据
- List<TChargingOrder> list = getSampleData();
- System.err.println(list);
- List<Map<String, BigDecimal>> result = processData(list);
- result.forEach(System.out::println);
+ @GetMapping(value = "/getGunIdsByUserId")
+ @ApiOperation(value = "查询当前用户正在充电中的枪id集合", tags = {"小程序-首页-用户充电订单信息"})
+ public R<List<Integer>> getGunIdsByUserId() {
+ Long userId = tokenService.getLoginUserApplet().getUserId();
+ List<TChargingOrder> list = chargingOrderService.list(Wrappers.lambdaQuery(TChargingOrder.class)
+ .eq(TChargingOrder::getAppUserId, userId)
+ .in(TChargingOrder::getStatus, Arrays.asList(1,2,3,4)));
+ List<Integer> gunIds = list.stream().map(TChargingOrder::getChargingGunId).collect(Collectors.toList());
+ return R.ok(gunIds);
}
+
private static List<TChargingOrder> getSampleData() {
@@ -1333,6 +1805,7 @@
*/
@PostMapping("/endCharge")
public void endCharge(@RequestParam("code") String code){
+ log.error(code + ":-------------------充电桩自动结束充电-------------------");
chargingOrderService.endCharge(code, 2);
}
@@ -1342,6 +1815,7 @@
*/
@PostMapping("/excelEndCharge")
public void excelEndCharge(@RequestParam("code") String code){
+ log.error(code + ":-------------------充电异常,停止充电-------------------");
chargingOrderService.excelEndCharge(code);
}
@@ -1366,4 +1840,28 @@
chargingOrderService.updateById(chargingOrder);
return R.ok();
}
+
+
+ @ResponseBody
+ @GetMapping(value = "/getEndOfChargePageInfo/{id}")
+ @ApiOperation(value = "获取充电结束页面数据", tags = {"小程序-扫一扫"})
+ @ApiImplicitParams({
+ @ApiImplicitParam(name = "id", value = "订单id", required = true)
+ })
+ public AjaxResult<EndOfChargePageInfo> getEndOfChargePageInfo(@PathVariable("id") String id){
+ EndOfChargePageInfo endOfChargePageInfo = chargingOrderService.getEndOfChargePageInfo(id);
+ return AjaxResult.success(endOfChargePageInfo);
+ }
+
+
+ /**
+ * 获取订单数据
+ * @param order
+ * @return
+ */
+ @PostMapping("/getChargingOrder")
+ public R<List<TChargingOrder>> getChargingOrder(@RequestBody TChargingOrderVo order){
+ List<TChargingOrder> chargingOrder = chargingOrderService.getChargingOrder(order);
+ return R.ok(chargingOrder);
+ }
}
--
Gitblit v1.7.1