ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/feignClient/ChargingPileClient.java
@@ -28,6 +28,10 @@ @PostMapping(value = "/t-charging-pile/getChargingPileBySiteId") R<List<TChargingPile>> getChargingPileBySiteId(@RequestParam("siteId") Integer siteId); @ApiOperation(value = "获取站点列表") @PostMapping(value = "/t-charging-pile/getChargingPileBySiteIds") R<List<TChargingPile>> getChargingPileBySiteIds(@RequestParam("siteIds") List<Integer> siteIds); /** * 小程序远程调用 根据会员折扣、预付金额 计算服务费 * @return ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/vo/TParkLotRecordCountVo.java
New file @@ -0,0 +1,19 @@ package com.ruoyi.chargingPile.api.vo; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.math.BigDecimal; import java.util.List; import java.util.Map; @Data public class TParkLotRecordCountVo { @ApiModelProperty("从左到右依次") int count1; int count2; int count3; int count4; BigDecimal count5; } ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/vo/TParkLotRecordVO.java
New file @@ -0,0 +1,20 @@ package com.ruoyi.chargingPile.api.vo; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.List; import java.util.Map; @Data public class TParkLotRecordVO { @ApiModelProperty("上方折线图") List<Map<String,Object>> maps; @ApiModelProperty("车辆类型饼图") List<Map<String,Object>> carColor; @ApiModelProperty("出场类型") List<Map<String,Object>> outType; @ApiModelProperty("进场充电占比") List<Map<String,Object>> isCharge; } ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/vo/TCharingUserEquimentVO.java
New file @@ -0,0 +1,25 @@ package com.ruoyi.order.api.vo; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.List; import java.util.Map; @Data public class TCharingUserEquimentVO { @ApiModelProperty("直流可用率") List<Map<String,Object>> equipmentMap1; @ApiModelProperty("交流可用率") List<Map<String,Object>> equipmentMap2; @ApiModelProperty("直流故障率") List<Map<String,Object>> equipmentMapbroke1; @ApiModelProperty("交流故障率") List<Map<String,Object>> equipmentMapbroke2; @ApiModelProperty("直流离网率") List<Map<String,Object>> equipmentMapOut1; @ApiModelProperty("交流离网率") List<Map<String,Object>> equipmentMapOut2; @ApiModelProperty("需求电流满足率") List<Map<String,Object>> needElec; } ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/vo/TCharingWorkVO.java
New file @@ -0,0 +1,23 @@ package com.ruoyi.order.api.vo; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.math.BigDecimal; import java.util.List; import java.util.Map; @Data public class TCharingWorkVO { @ApiModelProperty("订单数量") int count; @ApiModelProperty("充电总收入") BigDecimal totalPaymentAmount; @ApiModelProperty("充电电费") BigDecimal totalElectrovalence; @ApiModelProperty("累计服务费") BigDecimal totalServiceCharge; @ApiModelProperty("充电度数综合") BigDecimal totalChargingCapacity; } ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TChargingPileController.java
@@ -95,6 +95,11 @@ .eq(TChargingPile::getSiteId,siteId))); } @PostMapping(value = "/getChargingPileBySiteIds") public R<List<TChargingPile>> getChargingPileBySiteIds(@RequestParam("siteIds") List<Integer> siteIds) { return R.ok(chargingPileService.list(Wrappers.lambdaQuery(TChargingPile.class) .in(!siteIds.isEmpty(),TChargingPile::getSiteId,siteIds))); } @ResponseBody @GetMapping("/pageChargingPileList") @@ -162,6 +167,7 @@ return AjaxResult.success(chargeMonitoring); } @ResponseBody @GetMapping("/getChargingGunCountMonitoring/{siteId}") @ApiOperation(value = "获取充电枪各种状态汇总监控数据", tags = {"管理后台-充电设备监控"}) ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TParkingRecordController.java
@@ -8,10 +8,9 @@ import com.ruoyi.chargingPile.api.model.TParkingLot; import com.ruoyi.chargingPile.api.model.TParkingRecord; import com.ruoyi.chargingPile.api.query.ParkingRecordQuery; import com.ruoyi.chargingPile.api.vo.GetParkingRecord; import com.ruoyi.chargingPile.api.vo.TParkingRecordPageInfoVO; import com.ruoyi.chargingPile.api.vo.TParkingRecordVO; import com.ruoyi.chargingPile.api.vo.*; import com.ruoyi.chargingPile.dto.ParkingRecordPageQuery; import com.ruoyi.chargingPile.dto.ParkingRecordQueryDto; import com.ruoyi.chargingPile.export.TParkingRecordExport; import com.ruoyi.chargingPile.service.TParkingLotService; import com.ruoyi.chargingPile.service.TParkingRecordService; @@ -23,6 +22,7 @@ import com.ruoyi.common.log.annotation.Log; import com.ruoyi.common.log.enums.BusinessType; import com.ruoyi.order.api.query.TOrderInvoiceQuery; import com.ruoyi.order.api.vo.TCharingUserEquimentVO; import com.ruoyi.order.api.vo.TOrderInvoiceVO; import io.swagger.annotations.ApiOperation; import org.apache.poi.ss.usermodel.Workbook; @@ -33,9 +33,12 @@ import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.math.BigDecimal; import java.net.URLEncoder; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.stream.Collectors; /** * <p> @@ -179,5 +182,76 @@ public void addParkingRecord(@RequestBody TParkingRecord parkingRecord){ parkingRecordService.save(parkingRecord); } @ResponseBody @PostMapping(value = "/parking/data") @ApiOperation(value = "统计", tags = {"管理后台-数据分析-车场运营分析"}) public R<TParkLotRecordVO> data(@RequestBody ParkingRecordQueryDto parkingRecordQueryDto){ //上方折线图 TParkLotRecordVO tParkLotRecordVO = new TParkLotRecordVO(); if (parkingRecordQueryDto.getDayType()==1) { List<Map<String, Object>> maps = parkingRecordService.parkingData(parkingRecordQueryDto); tParkLotRecordVO.setMaps(maps); }else { List<Map<String, Object>> maps = parkingRecordService.parkingDataByDate(parkingRecordQueryDto); tParkLotRecordVO.setMaps(maps); } //车辆类型饼图 List<Map<String, Object>> carColor = parkingRecordService.getCarColor(parkingRecordQueryDto); //出场类型 List<Map<String, Object>> outType = parkingRecordService.getOutType(parkingRecordQueryDto); //进场充电占比 List<Map<String, Object>> isCharge = parkingRecordService.getIsCharge(parkingRecordQueryDto); tParkLotRecordVO.setCarColor(carColor); tParkLotRecordVO.setOutType(outType); tParkLotRecordVO.setIsCharge(isCharge); return R.ok(tParkLotRecordVO); } @ResponseBody @PostMapping(value = "/parking/work") @ApiOperation(value = "停车订单统计", tags = {"管理后台-工作台"}) public R<TParkLotRecordCountVo> work(@RequestBody ParkingRecordQueryDto parkingRecordQueryDto){ List<TParkingRecord> list = parkingRecordService.lambdaQuery().eq(parkingRecordQueryDto.getParkingLotId() != null, TParkingRecord::getParkingLotId, parkingRecordQueryDto.getParkingLotId()) .between(TParkingRecord::getCreateTime, parkingRecordQueryDto.getStartTime(), parkingRecordQueryDto.getEndTime()).list(); int count1 = list.size(); //统计出list中chargingOrderId为null的数据个数 int count2 = list.stream().filter(item -> item.getChargingOrderId() == null).collect(Collectors.toList()).size(); int count3 = count1-count2; //计算出list中parkingDuration的总和 int count4 = 0; for (TParkingRecord tParkingRecord : list) { count4 = count4+tParkingRecord.getParkingDuration(); } //计算出list中orderAmount的总和 BigDecimal count5 = list.stream().map(TParkingRecord::getOrderAmount).reduce(BigDecimal.ZERO, BigDecimal::add); TParkLotRecordCountVo tParkLotRecordCountVo = new TParkLotRecordCountVo(); tParkLotRecordCountVo.setCount1(count1); tParkLotRecordCountVo.setCount2(count2); tParkLotRecordCountVo.setCount3(count3); tParkLotRecordCountVo.setCount4(count4); tParkLotRecordCountVo.setCount5(count5); return R.ok(tParkLotRecordCountVo); } @ResponseBody @PostMapping(value = "/parking/income") @ApiOperation(value = "停车收入统计", tags = {"管理后台-工作台"}) public R income(@RequestBody ParkingRecordQueryDto parkingRecordQueryDto){ List<Map<String,Object>> maps = parkingRecordService.income(parkingRecordQueryDto); return R.ok(maps); } } ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/dto/ParkingRecordQueryDto.java
New file @@ -0,0 +1,18 @@ package com.ruoyi.chargingPile.dto; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.time.LocalDate; @Data public class ParkingRecordQueryDto { @ApiModelProperty("停车场Id") private Integer parkingLotId; @ApiModelProperty("1今日2本周3本月4今年5自定义") private Integer dayType; @ApiModelProperty("开始时间") private LocalDate startTime; @ApiModelProperty("结束时间") private LocalDate endTime; } ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/mapper/TParkingRecordMapper.java
@@ -5,12 +5,14 @@ import com.ruoyi.chargingPile.api.query.ParkingRecordQuery; import com.ruoyi.chargingPile.api.vo.TParkingRecordPageInfoVO; import com.ruoyi.chargingPile.api.vo.TParkingRecordVO; import com.ruoyi.chargingPile.dto.ParkingRecordQueryDto; import com.ruoyi.common.core.web.page.PageInfo; import org.apache.ibatis.annotations.Param; import java.math.BigDecimal; import java.time.LocalDate; import java.util.List; import java.util.Map; /** * <p> @@ -39,4 +41,15 @@ */ TParkingRecordPageInfoVO getParkingRecordCount(@Param("query")ParkingRecordQuery query); List<Map<String, Object>> parkingData(@Param("parkingRecordQueryDto") ParkingRecordQueryDto parkingRecordQueryDto); List<Map<String, Object>> parkingDataByDate(@Param("parkingRecordQueryDto")ParkingRecordQueryDto parkingRecordQueryDto); List<Map<String, Object>> getCarColor(@Param("parkingRecordQueryDto")ParkingRecordQueryDto parkingRecordQueryDto); List<Map<String, Object>> getOutType(@Param("parkingRecordQueryDto")ParkingRecordQueryDto parkingRecordQueryDto); List<Map<String, Object>> getIsCharge(@Param("parkingRecordQueryDto")ParkingRecordQueryDto parkingRecordQueryDto); List<Map<String, Object>> income(@Param("parkingRecordQueryDto")ParkingRecordQueryDto parkingRecordQueryDto); } ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/TChargingPileService.java
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/TParkingRecordService.java
@@ -4,10 +4,13 @@ import com.ruoyi.chargingPile.api.model.TParkingRecord; import com.ruoyi.chargingPile.api.query.ParkingRecordQuery; import com.ruoyi.chargingPile.api.vo.TParkingRecordPageInfoVO; import com.ruoyi.chargingPile.dto.ParkingRecordQueryDto; import com.ruoyi.common.core.web.page.PageInfo; import java.math.BigDecimal; import java.time.LocalDate; import java.util.List; import java.util.Map; /** * <p> @@ -27,4 +30,16 @@ * @return */ TParkingRecordPageInfoVO pageList(ParkingRecordQuery query); List<Map<String, Object>> parkingData(ParkingRecordQueryDto parkingRecordQueryDto); List<Map<String, Object>> parkingDataByDate(ParkingRecordQueryDto parkingRecordQueryDto); List<Map<String, Object>> getCarColor(ParkingRecordQueryDto parkingRecordQueryDto); List<Map<String, Object>> getOutType(ParkingRecordQueryDto parkingRecordQueryDto); List<Map<String, Object>> getIsCharge(ParkingRecordQueryDto parkingRecordQueryDto); List<Map<String, Object>> income(ParkingRecordQueryDto parkingRecordQueryDto); } ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingPileServiceImpl.java
@@ -345,6 +345,8 @@ return chargeMonitoring; } /** * 获取充电枪各种状态汇总 * @param siteId 站点id ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TParkingRecordServiceImpl.java
@@ -10,6 +10,7 @@ import com.ruoyi.chargingPile.api.vo.TParkingRecordPageInfoVO; import com.ruoyi.chargingPile.api.vo.TParkingRecordVO; import com.ruoyi.chargingPile.domain.SiteMenu; import com.ruoyi.chargingPile.dto.ParkingRecordQueryDto; import com.ruoyi.chargingPile.mapper.SiteMapper; import com.ruoyi.chargingPile.mapper.TParkingLotMapper; import com.ruoyi.chargingPile.mapper.TParkingRecordMapper; @@ -21,6 +22,7 @@ import java.math.BigDecimal; import java.time.LocalDate; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.stream.Collectors; @@ -73,4 +75,34 @@ infoVO.setParkingRecordVOS(pageInfo); return infoVO; } @Override public List<Map<String, Object>> parkingData(ParkingRecordQueryDto parkingRecordQueryDto) { return this.baseMapper.parkingData(parkingRecordQueryDto); } @Override public List<Map<String, Object>> parkingDataByDate(ParkingRecordQueryDto parkingRecordQueryDto) { return this.baseMapper.parkingDataByDate(parkingRecordQueryDto); } @Override public List<Map<String, Object>> getCarColor(ParkingRecordQueryDto parkingRecordQueryDto) { return this.baseMapper.getCarColor(parkingRecordQueryDto); } @Override public List<Map<String, Object>> getOutType(ParkingRecordQueryDto parkingRecordQueryDto) { return this.baseMapper.getOutType(parkingRecordQueryDto); } @Override public List<Map<String, Object>> getIsCharge(ParkingRecordQueryDto parkingRecordQueryDto) { return this.baseMapper.getIsCharge(parkingRecordQueryDto); } @Override public List<Map<String, Object>> income(ParkingRecordQueryDto parkingRecordQueryDto) { return this.baseMapper.income(parkingRecordQueryDto); } } ruoyi-service/ruoyi-chargingPile/src/main/resources/mapper/chargingPile/TParkingRecordMapper.xml
@@ -82,5 +82,173 @@ group by create_time ORDER BY create_time DESC </select> <select id="parkingData" resultType="java.util.Map"> SELECT DATE_FORMAT( create_time, '%Y-%m-%d %H' ) AS TIME, count( 1 ) AS orders, SUM( timeout_amount ) AS timeoutAmount FROM t_parking_record where DATE(create_time ) = CURDATE() <if test="parkingRecordQueryDto.parkingLotId !=null"> AND parking_lot_id = #{parkingRecordQueryDto.parkingLotId} </if> GROUP BY TIME ORDER BY TIME </select> <select id="parkingDataByDate" resultType="java.util.Map"> SELECT DATE_FORMAT( create_time, '%Y-%m-%d' ) AS TIME, count( 1 ) AS orders, SUM( timeout_amount ) AS timeoutAmount FROM t_parking_record <where> <if test="parkingRecordQueryDto.parkingLotId !=null"> AND parking_lot_id = #{parkingRecordQueryDto.parkingLotId} </if> <if test="parkingRecordQueryDto.dayType == 2"> AND WEEKOFYEAR( co.create_time ) = WEEKOFYEAR( CURDATE() ) </if> <if test="parkingRecordQueryDto.dayType == 3"> AND MONTH( co.create_time ) = MONTH(CURDATE()) </if> <if test="parkingRecordQueryDto.dayType == 4"> AND YEAR( co.create_time ) = YEAR(CURDATE() ) </if> <if test="parkingRecordQueryDto.dayType == 5"> <if test="parkingRecordQueryDto.startTime != null"> AND co.create_time >= #{parkingRecordQueryDto.startTime} </if> <if test="parkingRecordQueryDto.endTime != null"> AND co.create_time <= #{parkingRecordQueryDto.endTime} </if> </if> </where> GROUP BY TIME ORDER BY TIME </select> <select id="getCarColor" resultType="java.util.Map"> SELECT vehicle_color,count(1) as counts FROM t_parking_record <where> <if test="parkingRecordQueryDto.parkingLotId !=null"> AND parking_lot_id = #{parkingRecordQueryDto.parkingLotId} </if> <if test="parkingRecordQueryDto.dayType == 1"> AND DATE( create_time ) = CURDATE() </if> <if test="parkingRecordQueryDto.dayType == 2"> AND WEEKOFYEAR( co.create_time ) = WEEKOFYEAR( CURDATE() ) </if> <if test="parkingRecordQueryDto.dayType == 3"> AND MONTH( co.create_time ) = MONTH(CURDATE()) </if> <if test="parkingRecordQueryDto.dayType == 4"> AND YEAR( co.create_time ) = YEAR(CURDATE() ) </if> <if test="parkingRecordQueryDto.dayType == 5"> <if test="parkingRecordQueryDto.startTime != null"> AND co.create_time >= #{parkingRecordQueryDto.startTime} </if> <if test="parkingRecordQueryDto.endTime != null"> AND co.create_time <= #{parkingRecordQueryDto.endTime} </if> </if> </where> GROUP BY vehicle_color </select> <select id="getOutType" resultType="java.util.Map"> SELECT out_parking_type,count(1) as counts FROM t_parking_record <where> <if test="parkingRecordQueryDto.parkingLotId !=null"> AND parking_lot_id = #{parkingRecordQueryDto.parkingLotId} </if> <if test="parkingRecordQueryDto.dayType == 1"> AND DATE( create_time ) = CURDATE() </if> <if test="parkingRecordQueryDto.dayType == 2"> AND WEEKOFYEAR( co.create_time ) = WEEKOFYEAR( CURDATE() ) </if> <if test="parkingRecordQueryDto.dayType == 3"> AND MONTH( co.create_time ) = MONTH(CURDATE()) </if> <if test="parkingRecordQueryDto.dayType == 4"> AND YEAR( co.create_time ) = YEAR(CURDATE() ) </if> <if test="parkingRecordQueryDto.dayType == 5"> <if test="parkingRecordQueryDto.startTime != null"> AND co.create_time >= #{parkingRecordQueryDto.startTime} </if> <if test="parkingRecordQueryDto.endTime != null"> AND co.create_time <= #{parkingRecordQueryDto.endTime} </if> </if> </where> GROUP BY out_parking_type </select> <select id="getIsCharge" resultType="java.util.Map"> SELECT CASE WHEN charging_order_id IS NOT NULL THEN 'WithChargingOrder' ELSE 'WithoutChargingOrder' END AS order_status, COUNT(*) AS counts FROM `t_parking_record` <where> <if test="parkingRecordQueryDto.parkingLotId !=null"> AND parking_lot_id = #{parkingRecordQueryDto.parkingLotId} </if> <if test="parkingRecordQueryDto.dayType == 1"> AND DATE( create_time ) = CURDATE() </if> <if test="parkingRecordQueryDto.dayType == 2"> AND WEEKOFYEAR( co.create_time ) = WEEKOFYEAR( CURDATE() ) </if> <if test="parkingRecordQueryDto.dayType == 3"> AND MONTH( co.create_time ) = MONTH(CURDATE()) </if> <if test="parkingRecordQueryDto.dayType == 4"> AND YEAR( co.create_time ) = YEAR(CURDATE() ) </if> <if test="parkingRecordQueryDto.dayType == 5"> <if test="parkingRecordQueryDto.startTime != null"> AND co.create_time >= #{parkingRecordQueryDto.startTime} </if> <if test="parkingRecordQueryDto.endTime != null"> AND co.create_time <= #{parkingRecordQueryDto.endTime} </if> </if> </where> GROUP BY order_status </select> <select id="income" resultType="java.util.Map"> SELECT sum(pr.order_amount) as amount,pl.name from t_parking_record pr LEFT JOIN t_parking_lot pl on pr.parking_lot_id = pl.id <where> <if test="parkingRecordQueryDto.parkingLotId !=null"> AND pr.parking_lot_id = #{parkingRecordQueryDto.parkingLotId} </if> AND DATE( pr.create_time ) between #{parkingRecordQueryDto.startTime} and #{parkingRecordQueryDto.endTime} </where> GROUP BY pl.name </select> </mapper> ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java
@@ -3,6 +3,7 @@ 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; @@ -583,6 +584,16 @@ } @ResponseBody @GetMapping(value = "/work/shop") @ApiOperation(value = "购物收入", tags = {"后台-工作台"}) public R workShop(@RequestBody ChargingStatisticsQueryDto statisticsQueryDto) { //count近6个月的数据 LocalDate sixBefore = PreviousSixMonths.get(); List<Map<String,Object >> shopData = shoppingOrderService.getData(statisticsQueryDto); return R.ok(shopData); } @ResponseBody @GetMapping(value = "/six/vip") @ApiOperation(value = "vip收入", tags = {"后台-数据分析-平台收入分析"}) public R<List<SixVipDto>> vip() { @@ -866,7 +877,7 @@ @ResponseBody @PostMapping(value = "/charging/equipment") @ApiOperation(value = "电站评价", tags = {"管理后台-数据分析-设备运维分析"}) public R<TCharingUserEvaluateVO> equipment(@RequestBody ChargingStatisticsQueryDto statisticsQueryDto){ public R<TCharingUserEquimentVO> equipment(@RequestBody ChargingStatisticsQueryDto statisticsQueryDto){ List<Integer> siteIds =new ArrayList<>(); if (statisticsQueryDto.getSiteId()==null) { Long userId = SecurityUtils.getUserId(); @@ -893,11 +904,152 @@ //需求电流满足率 List<Map<String,Object>> needElec = chargingOrderService.needElec(siteIds,statisticsQueryDto); TCharingUserEquimentVO tCharingUserEquimentVO = new TCharingUserEquimentVO(); tCharingUserEquimentVO.setEquipmentMap1(equipmentMap1); tCharingUserEquimentVO.setEquipmentMap2(equipmentMap2); tCharingUserEquimentVO.setEquipmentMapbroke1(equipmentMapbroke1); tCharingUserEquimentVO.setEquipmentMapbroke2(equipmentMapbroke2); tCharingUserEquimentVO.setEquipmentMapOut1(equipmentMapOut1); tCharingUserEquimentVO.setEquipmentMapOut2(equipmentMapOut2); tCharingUserEquimentVO.setNeedElec(needElec); return R.ok(tCharingUserEquimentVO); } @ResponseBody @PostMapping(value = "/work/charge") @ApiOperation(value = "上方充电数据统计", tags = {"管理后台-工作台"}) public R<TCharingWorkVO> workCharge(@RequestBody ChargingStatisticsQueryDto statisticsQueryDto) { List<Integer> siteIds = new ArrayList<>(); if (statisticsQueryDto.getSiteId() == null) { Long userId = SecurityUtils.getUserId(); //获取当前登录的siteIds List<GetSiteListDTO> data = siteClient.getSiteListByUserId(userId).getData(); for (GetSiteListDTO datum : data) { siteIds.add(datum.getId()); } } 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(); //当日的订单总数 int size = list.size(); //计算list中paymentAmount的总和 BigDecimal totalPaymentAmount = list.stream().map(TChargingOrder::getOrderAmount).reduce(BigDecimal.ZERO, BigDecimal::add); //计算list中electrovalence的总和 BigDecimal totalElectrovalence = list.stream().map(TChargingOrder::getElectrovalence).reduce(BigDecimal.ZERO, BigDecimal::add); //计算list中serviceCharge的总和 BigDecimal totalServiceCharge = list.stream().map(TChargingOrder::getServiceCharge).reduce(BigDecimal.ZERO, BigDecimal::add); //计算list中charging_capacity的总和 BigDecimal totalChargingCapacity = list.stream().map(TChargingOrder::getChargingCapacity).reduce(BigDecimal.ZERO, BigDecimal::add); TCharingWorkVO tCharingWorkVO = new TCharingWorkVO(); tCharingWorkVO.setCount(size); tCharingWorkVO.setTotalPaymentAmount(totalPaymentAmount); tCharingWorkVO.setTotalElectrovalence(totalElectrovalence); tCharingWorkVO.setTotalServiceCharge(totalServiceCharge); tCharingWorkVO.setTotalChargingCapacity(totalChargingCapacity); return R.ok(tCharingWorkVO); } @ResponseBody @PostMapping(value = "/work/chargeDetail") @ApiOperation(value = "运营情况", tags = {"管理后台-工作台"}) public R workCharge(@RequestBody ChargingDetailQueryDto statisticsQueryDto) { List<Integer> siteIds = new ArrayList<>(); if (statisticsQueryDto.getSiteId() == null) { Long userId = SecurityUtils.getUserId(); //获取当前登录的siteIds List<GetSiteListDTO> data = siteClient.getSiteListByUserId(userId).getData(); for (GetSiteListDTO datum : data) { siteIds.add(datum.getId()); } } else { siteIds.add(statisticsQueryDto.getSiteId()); } if (statisticsQueryDto.getDayType()==1) { List<Map<String,Object>> charMap = chargingOrderService.getHourType(siteIds,statisticsQueryDto); return R.ok(charMap); }else if (statisticsQueryDto.getDayType()==2){ List<Map<String,Object>> charMap = chargingOrderService.getDateType(siteIds,statisticsQueryDto); return R.ok(charMap); }else if (statisticsQueryDto.getDayType()==3){ List<Map<String,Object>> charMap = chargingOrderService.getMonthType(siteIds,statisticsQueryDto); } return R.ok(); } @ResponseBody @PostMapping(value = "/work/use") @ApiOperation(value = "运营情况", tags = {"管理后台-工作台"}) public R workUse(@RequestBody ChargingDetailQueryDto statisticsQueryDto) { List<Integer> siteIds = new ArrayList<>(); if (statisticsQueryDto.getSiteId() == null) { Long userId = SecurityUtils.getUserId(); //获取当前登录的siteIds List<GetSiteListDTO> data = siteClient.getSiteListByUserId(userId).getData(); for (GetSiteListDTO datum : data) { siteIds.add(datum.getId()); } } else { siteIds.add(statisticsQueryDto.getSiteId()); } List<Map<String,Object>> capMap = chargingOrderService.getchargingCapacity(siteIds,statisticsQueryDto); List<TChargingPile> chargingPiles = chargingPileClient.getChargingPileBySiteIds(siteIds).getData(); //获取chargingPiles的ratedPower的总和再乘以chargingPiles的数量再乘以24 BigDecimal totalRatedPower = chargingPiles.stream().map(TChargingPile::getRatedPower).reduce(BigDecimal.ZERO, BigDecimal::add).multiply(new BigDecimal(chargingPiles.size())).multiply(new BigDecimal(24)); //将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); }); return R.ok(capMap); } @Resource private TOrderInvoiceService invoiceService; @ResponseBody @PostMapping(value = "/work/shopOrder") @ApiOperation(value = "购物订单统计", tags = {"管理后台-工作台"}) public R shopOrder(@RequestBody ChargingStatisticsQueryDto statisticsQueryDto) { Long count = shoppingOrderService.lambdaQuery().eq(TShoppingOrder::getStatus, 1).count(); Long count1 = shoppingOrderService.lambdaQuery().eq(TShoppingOrder::getStatus, 2).count(); List<Long> counts = new ArrayList<>(); counts.add(count); counts.add(count1); return R.ok(counts); } @ResponseBody @PostMapping(value = "/work/invoice") @ApiOperation(value = "开票统计", tags = {"管理后台-工作台"}) public R invoice(@RequestBody ChargingStatisticsQueryDto statisticsQueryDto) { Long count = invoiceService.lambdaQuery().eq(TOrderInvoice::getStatus, 1).count(); Long count1 = invoiceService.lambdaQuery().eq(TOrderInvoice::getStatus, 3).count(); List<Long> counts = new ArrayList<>(); counts.add(count); counts.add(count1); return R.ok(counts); } @ResponseBody @PostMapping(value = "/work/users/count") @ApiOperation(value = "用户数量", tags = {"管理后台-工作台"}) public R usersCount(@RequestBody ChargingStatisticsQueryDto statisticsQueryDto) { List<Map<String,Object>> userMap = chargingOrderService.countAllUserData(); return R.ok(userMap); } public static void main(String[] args) { // 示例数据 List<TChargingOrder> list = getSampleData(); ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/dto/ChargingDetailQueryDto.java
New file @@ -0,0 +1,23 @@ package com.ruoyi.order.dto; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.time.LocalDate; @Data public class ChargingDetailQueryDto { @ApiModelProperty("电站id") private Integer siteId; @ApiModelProperty("1时2日3月") private Integer dayType; @ApiModelProperty("1开始或2结束") private Integer type; @ApiModelProperty("时用Date") private LocalDate hourDate; @ApiModelProperty("开始时间") private LocalDate startTime; @ApiModelProperty("结束时间") private LocalDate endTime; } ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/dto/ChargingStatisticsQueryDto.java
@@ -15,4 +15,6 @@ private LocalDate startTime; @ApiModelProperty("结束时间") private LocalDate endTime; @ApiModelProperty("工作台用查询参数") private LocalDate selectDate; } ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TChargingOrderMapper.java
@@ -121,4 +121,16 @@ List<Map<String, Object>> equipmentMapOut1(@Param("siteIds")List<Integer> siteIds, @Param("statisticsQueryDto")ChargingStatisticsQueryDto statisticsQueryDto); List<Map<String, Object>> equipmentMapOut2(@Param("siteIds")List<Integer> siteIds,@Param("statisticsQueryDto") ChargingStatisticsQueryDto statisticsQueryDto); List<Map<String, Object>> needElec(@Param("siteIds")List<Integer> siteIds, @Param("statisticsQueryDto")ChargingStatisticsQueryDto statisticsQueryDto); List<Map<String, Object>> getHourType(@Param("siteIds")List<Integer> siteIds, @Param("statisticsQueryDto")ChargingDetailQueryDto statisticsQueryDto); List<Map<String, Object>> getDateType(@Param("siteIds")List<Integer> siteIds,@Param("statisticsQueryDto") ChargingDetailQueryDto statisticsQueryDto); List<Map<String, Object>> getMonthType(@Param("siteIds")List<Integer> siteIds, @Param("statisticsQueryDto")ChargingDetailQueryDto statisticsQueryDto); List<Map<String, Object>> getchargingCapacity(@Param("siteIds")List<Integer> siteIds,@Param("statisticsQueryDto") ChargingDetailQueryDto statisticsQueryDto); List<Map<String, Object>> countAllUserData(); } ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TShoppingOrderMapper.java
@@ -6,6 +6,7 @@ import com.ruoyi.order.api.query.ShoppingOrderQuery; import com.ruoyi.order.api.query.TActivityStatisticsQuery; import com.ruoyi.order.api.vo.TActivityStatisticslVO; import com.ruoyi.order.dto.ChargingStatisticsQueryDto; import com.ruoyi.order.dto.SixShopDto; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -13,6 +14,7 @@ import java.math.BigDecimal; import java.time.LocalDate; import java.util.List; import java.util.Map; /** * <p> @@ -44,4 +46,6 @@ List<SixShopDto> sixBefore(@Param("sixBefore")LocalDate sixBefore,@Param("status") Integer status); BigDecimal getSumAmount(@Param("sixBefore")LocalDate sixBefore); List<Map<String, Object>> getData(@Param("statisticsQueryDto")ChargingStatisticsQueryDto statisticsQueryDto); } ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/TChargingOrderService.java
@@ -214,4 +214,16 @@ List<Map<String, Object>> equipmentMapOut1(List<Integer> siteIds, ChargingStatisticsQueryDto statisticsQueryDto); List<Map<String, Object>> equipmentMapOut2(List<Integer> siteIds, ChargingStatisticsQueryDto statisticsQueryDto); List<Map<String, Object>> needElec(List<Integer> siteIds, ChargingStatisticsQueryDto statisticsQueryDto); List<Map<String, Object>> getHourType(List<Integer> siteIds, ChargingDetailQueryDto statisticsQueryDto); List<Map<String, Object>> getDateType(List<Integer> siteIds, ChargingDetailQueryDto statisticsQueryDto); List<Map<String, Object>> getMonthType(List<Integer> siteIds, ChargingDetailQueryDto statisticsQueryDto); List<Map<String, Object>> getchargingCapacity(List<Integer> siteIds, ChargingDetailQueryDto statisticsQueryDto); List<Map<String, Object>> countAllUserData(); } ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/TShoppingOrderService.java
@@ -80,4 +80,6 @@ List<SixShopDto> sixBefore(LocalDate sixBefore, Integer status); BigDecimal getSumAmount(LocalDate sixBefore); List<Map<String, Object>> getData(ChargingStatisticsQueryDto statisticsQueryDto); } ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java
@@ -2132,6 +2132,36 @@ return this.baseMapper.equipmentMapOut2(siteIds,statisticsQueryDto); } @Override public List<Map<String, Object>> needElec(List<Integer> siteIds, ChargingStatisticsQueryDto statisticsQueryDto) { return this.baseMapper.needElec(siteIds,statisticsQueryDto); } @Override public List<Map<String, Object>> getHourType(List<Integer> siteIds, ChargingDetailQueryDto statisticsQueryDto) { return this.baseMapper.getHourType(siteIds,statisticsQueryDto); } @Override public List<Map<String, Object>> getDateType(List<Integer> siteIds, ChargingDetailQueryDto statisticsQueryDto) { return this.baseMapper.getDateType(siteIds,statisticsQueryDto); } @Override public List<Map<String, Object>> getMonthType(List<Integer> siteIds, ChargingDetailQueryDto statisticsQueryDto) { return this.baseMapper.getMonthType(siteIds,statisticsQueryDto); } @Override public List<Map<String, Object>> getchargingCapacity(List<Integer> siteIds, ChargingDetailQueryDto statisticsQueryDto) { return this.baseMapper.getchargingCapacity(siteIds,statisticsQueryDto); } @Override public List<Map<String, Object>> countAllUserData() { return this.baseMapper.countAllUserData(); } public static void main(String[] args) { // String format = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日HH:mm:ss")); // String format1 = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日HH:mm:ss")); ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TShoppingOrderServiceImpl.java
@@ -547,5 +547,10 @@ return this.baseMapper.getSumAmount(sixBefore); } @Override public List<Map<String, Object>> getData(ChargingStatisticsQueryDto statisticsQueryDto) { return this.baseMapper.getData(statisticsQueryDto); } } ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml
@@ -908,6 +908,26 @@ #{siteId} </foreach> </if> <if test="statisticsQueryDto.dayType == 1"> AND DATE( co.create_time ) = CURDATE() </if> <if test="statisticsQueryDto.dayType == 2"> AND WEEKOFYEAR( co.create_time ) = WEEKOFYEAR( CURDATE() ) </if> <if test="statisticsQueryDto.dayType == 3"> AND MONTH( co.create_time ) = MONTH(CURDATE()) </if> <if test="statisticsQueryDto.dayType == 4"> AND YEAR( co.create_time ) = YEAR(CURDATE() ) </if> <if test="statisticsQueryDto.dayType == 5"> <if test="statisticsQueryDto.startTime != null"> AND co.create_time >= #{statisticsQueryDto.startTime} </if> <if test="statisticsQueryDto.endTime != null"> AND co.create_time <= #{statisticsQueryDto.endTime} </if> </if> GROUP BY tc.name,cp.name,co.charging_gun_id @@ -948,6 +968,26 @@ #{siteId} </foreach> </if> <if test="statisticsQueryDto.dayType == 1"> AND DATE( co.create_time ) = CURDATE() </if> <if test="statisticsQueryDto.dayType == 2"> AND WEEKOFYEAR( co.create_time ) = WEEKOFYEAR( CURDATE() ) </if> <if test="statisticsQueryDto.dayType == 3"> AND MONTH( co.create_time ) = MONTH(CURDATE()) </if> <if test="statisticsQueryDto.dayType == 4"> AND YEAR( co.create_time ) = YEAR(CURDATE() ) </if> <if test="statisticsQueryDto.dayType == 5"> <if test="statisticsQueryDto.startTime != null"> AND co.create_time >= #{statisticsQueryDto.startTime} </if> <if test="statisticsQueryDto.endTime != null"> AND co.create_time <= #{statisticsQueryDto.endTime} </if> </if> GROUP BY tc.name,cp.name,co.charging_gun_id @@ -979,6 +1019,32 @@ LEFT JOIN `charging_pile_service`.`t_charging_pile` cp on tc.charging_pile_id = cp.id WHERE co.down_time IS NOT NULL AND co.end_time IS NOT NULL and cp.type = 1 and co.status =2 <if test="siteIds != null and siteIds.size() > 0"> and co.site_id IN <foreach collection="siteIds" item="siteId" open="(" separator="," close=")"> #{siteId} </foreach> </if> <if test="statisticsQueryDto.dayType == 1"> AND DATE( co.create_time ) = CURDATE() </if> <if test="statisticsQueryDto.dayType == 2"> AND WEEKOFYEAR( co.create_time ) = WEEKOFYEAR( CURDATE() ) </if> <if test="statisticsQueryDto.dayType == 3"> AND MONTH( co.create_time ) = MONTH(CURDATE()) </if> <if test="statisticsQueryDto.dayType == 4"> AND YEAR( co.create_time ) = YEAR(CURDATE() ) </if> <if test="statisticsQueryDto.dayType == 5"> <if test="statisticsQueryDto.startTime != null"> AND co.create_time >= #{statisticsQueryDto.startTime} </if> <if test="statisticsQueryDto.endTime != null"> AND co.create_time <= #{statisticsQueryDto.endTime} </if> </if> GROUP BY tc.name,cp.name,co.charging_gun_id @@ -1010,6 +1076,32 @@ LEFT JOIN `charging_pile_service`.`t_charging_pile` cp on tc.charging_pile_id = cp.id WHERE co.down_time IS NOT NULL AND co.end_time IS NOT NULL and cp.type = 2 and co.status =2 <if test="siteIds != null and siteIds.size() > 0"> and co.site_id IN <foreach collection="siteIds" item="siteId" open="(" separator="," close=")"> #{siteId} </foreach> </if> <if test="statisticsQueryDto.dayType == 1"> AND DATE( co.create_time ) = CURDATE() </if> <if test="statisticsQueryDto.dayType == 2"> AND WEEKOFYEAR( co.create_time ) = WEEKOFYEAR( CURDATE() ) </if> <if test="statisticsQueryDto.dayType == 3"> AND MONTH( co.create_time ) = MONTH(CURDATE()) </if> <if test="statisticsQueryDto.dayType == 4"> AND YEAR( co.create_time ) = YEAR(CURDATE() ) </if> <if test="statisticsQueryDto.dayType == 5"> <if test="statisticsQueryDto.startTime != null"> AND co.create_time >= #{statisticsQueryDto.startTime} </if> <if test="statisticsQueryDto.endTime != null"> AND co.create_time <= #{statisticsQueryDto.endTime} </if> </if> GROUP BY tc.name,cp.name,co.charging_gun_id @@ -1041,6 +1133,32 @@ LEFT JOIN `charging_pile_service`.`t_charging_pile` cp on tc.charging_pile_id = cp.id WHERE co.down_time IS NOT NULL AND co.end_time IS NOT NULL and cp.type = 1 and co.status =1 <if test="siteIds != null and siteIds.size() > 0"> and co.site_id IN <foreach collection="siteIds" item="siteId" open="(" separator="," close=")"> #{siteId} </foreach> </if> <if test="statisticsQueryDto.dayType == 1"> AND DATE( co.create_time ) = CURDATE() </if> <if test="statisticsQueryDto.dayType == 2"> AND WEEKOFYEAR( co.create_time ) = WEEKOFYEAR( CURDATE() ) </if> <if test="statisticsQueryDto.dayType == 3"> AND MONTH( co.create_time ) = MONTH(CURDATE()) </if> <if test="statisticsQueryDto.dayType == 4"> AND YEAR( co.create_time ) = YEAR(CURDATE() ) </if> <if test="statisticsQueryDto.dayType == 5"> <if test="statisticsQueryDto.startTime != null"> AND co.create_time >= #{statisticsQueryDto.startTime} </if> <if test="statisticsQueryDto.endTime != null"> AND co.create_time <= #{statisticsQueryDto.endTime} </if> </if> GROUP BY tc.name,cp.name,co.charging_gun_id </select> <select id="equipmentMapOut2" resultType="java.util.Map"> @@ -1070,7 +1188,225 @@ LEFT JOIN `charging_pile_service`.`t_charging_pile` cp on tc.charging_pile_id = cp.id WHERE co.down_time IS NOT NULL AND co.end_time IS NOT NULL and cp.type = 2 and co.status =1 <if test="siteIds != null and siteIds.size() > 0"> and co.site_id IN <foreach collection="siteIds" item="siteId" open="(" separator="," close=")"> #{siteId} </foreach> </if> <if test="statisticsQueryDto.dayType == 1"> AND DATE( co.create_time ) = CURDATE() </if> <if test="statisticsQueryDto.dayType == 2"> AND WEEKOFYEAR( co.create_time ) = WEEKOFYEAR( CURDATE() ) </if> <if test="statisticsQueryDto.dayType == 3"> AND MONTH( co.create_time ) = MONTH(CURDATE()) </if> <if test="statisticsQueryDto.dayType == 4"> AND YEAR( co.create_time ) = YEAR(CURDATE() ) </if> <if test="statisticsQueryDto.dayType == 5"> <if test="statisticsQueryDto.startTime != null"> AND co.create_time >= #{statisticsQueryDto.startTime} </if> <if test="statisticsQueryDto.endTime != null"> AND co.create_time <= #{statisticsQueryDto.endTime} </if> </if> GROUP BY tc.name,cp.name,co.charging_gun_id </select> <select id="needElec" resultType="java.util.Map"> SELECT FORMAT((SUM(co.current) / SUM(co.need_elec)), 2) AS percent, co.charging_gun_id, tc.name, cp.name AS gun_name FROM `charging_pile_order`.`t_charging_order` co LEFT JOIN `charging_pile_service`.`t_charging_gun` tc ON co.charging_gun_id = tc.id LEFT JOIN `charging_pile_service`.`t_charging_pile` cp ON tc.charging_pile_id = cp.id <where> <if test="siteIds != null and siteIds.size() > 0"> and co.site_id IN <foreach collection="siteIds" item="siteId" open="(" separator="," close=")"> #{siteId} </foreach> </if> <if test="statisticsQueryDto.dayType == 1"> AND DATE( co.create_time ) = CURDATE() </if> <if test="statisticsQueryDto.dayType == 2"> AND WEEKOFYEAR( co.create_time ) = WEEKOFYEAR( CURDATE() ) </if> <if test="statisticsQueryDto.dayType == 3"> AND MONTH( co.create_time ) = MONTH(CURDATE()) </if> <if test="statisticsQueryDto.dayType == 4"> AND YEAR( co.create_time ) = YEAR(CURDATE() ) </if> <if test="statisticsQueryDto.dayType == 5"> <if test="statisticsQueryDto.startTime != null"> AND co.create_time >= #{statisticsQueryDto.startTime} </if> <if test="statisticsQueryDto.endTime != null"> AND co.create_time <= #{statisticsQueryDto.endTime} </if> </if> </where> GROUP BY tc.name, cp.name, co.charging_gun_id; </select> <select id="getHourType" resultType="java.util.Map"> SELECT DATE_FORMAT( <if test="statisticsQueryDto.type == 1"> start_time </if> <if test="statisticsQueryDto.type == 2"> end_time </if> , '%Y-%m-%d %H' ) as time, SUM(service_charge) as servicecharge, SUM(electrovalence) as electrovalence, count(1) as orderCount FROM t_charging_order WHERE del_flag = 0 and recharge_payment_status = 2 and DATE( <if test="statisticsQueryDto.type == 1"> start_time </if> <if test="statisticsQueryDto.type == 2"> end_time </if> ) = #{statisticsQueryDto.hourDate} <if test="siteIds != null and siteIds.size() > 0"> and site_id IN <foreach collection="siteIds" item="siteId" open="(" separator="," close=")"> #{siteId} </foreach> </if> GROUP BY time ORDER BY time </select> <select id="getDateType" resultType="java.util.Map"> SELECT DATE_FORMAT( <if test="statisticsQueryDto.type == 1"> start_time </if> <if test="statisticsQueryDto.type == 2"> end_time </if> , '%Y-%m-%d' ) as time, SUM(service_charge) as servicecharge, SUM(electrovalence) as electrovalence, count(1) as orderCount FROM t_charging_order WHERE del_flag = 0 and recharge_payment_status = 2 and DATE( <if test="statisticsQueryDto.type == 1"> start_time </if> <if test="statisticsQueryDto.type == 2"> end_time </if> ) between #{statisticsQueryDto.startTime} and #{statisticsQueryDto.endTime} <if test="siteIds != null and siteIds.size() > 0"> and site_id IN <foreach collection="siteIds" item="siteId" open="(" separator="," close=")"> #{siteId} </foreach> </if> GROUP BY time ORDER BY time </select> <select id="getMonthType" resultType="java.util.Map"> SELECT DATE_FORMAT( <if test="statisticsQueryDto.type == 1"> start_time </if> <if test="statisticsQueryDto.type == 2"> end_time </if> , '%Y-%m' ) as time, SUM(service_charge) as servicecharge, SUM(electrovalence) as electrovalence, count(1) as orderCount FROM t_charging_order WHERE del_flag = 0 and recharge_payment_status = 2 and DATE( <if test="statisticsQueryDto.type == 1"> start_time </if> <if test="statisticsQueryDto.type == 2"> end_time </if> ) between #{statisticsQueryDto.startTime} and #{statisticsQueryDto.endTime} <if test="siteIds != null and siteIds.size() > 0"> and site_id IN <foreach collection="siteIds" item="siteId" open="(" separator="," close=")"> #{siteId} </foreach> </if> GROUP BY time ORDER BY time </select> <select id="getchargingCapacity" resultType="java.util.Map"> SELECT DATE_FORMAT( create_time, '%Y-%m-%d %H' ) as time, SUM(charging_capacity) as chargingCapacity FROM t_charging_order WHERE del_flag = 0 and recharge_payment_status = 2 <if test="statisticsQueryDto.dayType == 1"> AND DATE( create_time ) between #{statisticsQueryDto.startTime} and #{statisticsQueryDto.endTime} </if> GROUP BY time ORDER BY time </select> <select id="countAllUserData" resultType="java.util.Map"> SELECT COUNT( DISTINCT app_user_id ) AS counts, '1' AS type FROM `charging_pile_order`.`t_charging_order` UNION ALL SELECT COUNT(*) AS counts, '2' AS type FROM `charging_pile_account`.`t_app_user` WHERE `vip_end_time` > NOW() UNION ALL SELECT COUNT(*) AS counts, '3' AS type FROM `charging_pile_account`.`t_app_user` WHERE del_flag = 0 </select> </mapper> ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TShoppingOrderMapper.xml
@@ -292,4 +292,31 @@ and DATE_FORMAT(create_time, '%Y-%m-%d') >= DATE_FORMAT(#{sixBefore}, '%Y-%m-%d') </if> </select> <select id="getData" resultType="java.util.Map"> SELECT DATE_FORMAT( subquery.create_time, '%Y-%m-%d' ) AS MONTH, count(1) AS orderNum, SUM(payment_amount) AS paymentAmount FROM ( SELECT create_time, payment_amount FROM t_shopping_order <where> WHERE del_flag = 0 and payment_status = 2 and ISNULL(refund_status) and status!=4 DATE_FORMAT(create_time, '%Y-%m-%d') between #{statisticsQueryDto.startTime} and #{statisticsQueryDto.endTime} </where> ) AS subquery GROUP BY DATE_FORMAT( subquery.create_time, '%Y-%m-%d' ); </select> </mapper> ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TGoodsController.java
@@ -185,6 +185,7 @@ //检查当前用户积分是否够 Long userId = tokenService.getLoginUserApplet().getUserId(); Integer point = 0; TAppUser user = appUserClient.getUserById(userId).getData(); if (exchangeDto.getGoodType()==1) { //查询当前商品信息 @@ -195,7 +196,6 @@ if (good.getLimitExchangeTimes() != -1 && count >= good.getLimitExchangeTimes()) { return AjaxResult.error("当前用户已兑换"+count+"张"); } TAppUser user = appUserClient.getUserById(userId).getData(); if (user.getPoints()<good.getRedeemPoints()){ return AjaxResult.error("当前用户积分不足"); } @@ -207,6 +207,9 @@ if (coupon.getInventoryQuantity() != -1 && count >= coupon.getInventoryQuantity()) { return AjaxResult.error("当前用户已到达兑换"+coupon+"次"); } if (user.getPoints()<point){ return AjaxResult.error("当前用户积分不足"); } } exchangeDto.setPoint(point); exchangeDto.setUserId(userId);