puzhibing
2024-09-12 a738f7d328e037abe189c14c94d7ef835bf8296c
Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/mx_charging_pile
31个文件已修改
8个文件已添加
1636 ■■■■■ 已修改文件
ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/feignClient/ChargingPileClient.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/vo/GunStatusStatisticsVO.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/vo/StatusModeStatisticsVO.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/vo/TParkLotRecordCountVo.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/vo/TParkLotRecordVO.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/vo/TCharingUserEquimentVO.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/vo/TCharingUserEvaluateVO.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/vo/TCharingWorkVO.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TChargingGunController.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TChargingPileController.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TParkingRecordController.java 80 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/dto/ParkingRecordQueryDto.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/mapper/TChargingGunMapper.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/mapper/TParkingRecordMapper.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/TChargingGunService.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/TChargingPileService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/TParkingRecordService.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingGunServiceImpl.java 68 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingPileServiceImpl.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TParkingRecordServiceImpl.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/resources/mapper/chargingPile/TChargingGunMapper.xml 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/resources/mapper/chargingPile/TParkingRecordMapper.xml 168 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java 203 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/dto/ChargingDetailQueryDto.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/dto/ChargingStatisticsQueryDto.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TChargingOrderMapper.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TOrderEvaluateMapper.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TShoppingOrderMapper.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/TChargingOrderService.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/TOrderEvaluateService.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/TShoppingOrderService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java 65 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TOrderEvaluateServiceImpl.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TShoppingOrderServiceImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml 552 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TOrderEvaluateMapper.xml 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TShoppingOrderMapper.xml 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TCouponController.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TGoodsController.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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/GunStatusStatisticsVO.java
New file
@@ -0,0 +1,21 @@
package com.ruoyi.chargingPile.api.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
@Data
@ApiModel(value = "设备状态统计VO")
public class GunStatusStatisticsVO implements Serializable {
    @ApiModelProperty(value = "充电桩类型统计 key:充电模式(1=超级快充,2=快充,3=慢充)")
    private Map<Integer,Integer> modeStatistics;
    @ApiModelProperty(value = "状态统计 key:充电模式(1=离线,2=故障,3=充电中)")
    private Map<Integer,Integer> statusStatistics;
    @ApiModelProperty(value = "状态统计根据类型分组")
    private List<StatusModeStatisticsVO> statusModeStatistics;
}
ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/vo/StatusModeStatisticsVO.java
New file
@@ -0,0 +1,33 @@
package com.ruoyi.chargingPile.api.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@ApiModel(value = "状态统计根据类型分组VO")
public class StatusModeStatisticsVO implements Serializable {
    @ApiModelProperty(value = "充电模式(1=超级快充,2=快充,3=慢充)")
    private Integer chargeMode;
    @ApiModelProperty(value = "空闲")
    private Integer freeCount;
    @ApiModelProperty(value = "充满")
    private Integer filledCount;
    @ApiModelProperty(value = "插枪")
    private Integer insertCount;
    @ApiModelProperty(value = "充电中")
    private Integer chargingCount;
}
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/TCharingUserEvaluateVO.java
@@ -14,5 +14,11 @@
    List<Map<String,Object>> evaluate;
    @ApiModelProperty("差评数量")
    Long blackCount;
    @ApiModelProperty("好评标签")
    List<Map<String,Object>> goodTop;
    @ApiModelProperty("差评标签")
    List<Map<String,Object>> badTop;
    @ApiModelProperty("流量分析")
    List<Map<String,Object>> flow;
}
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/TChargingGunController.java
@@ -4,12 +4,14 @@
import cn.hutool.core.img.ImgUtil;
import cn.hutool.core.io.FileUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.chargingPile.api.dto.GetSiteListDTO;
import com.ruoyi.chargingPile.api.dto.TChargingGunDTO;
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.TFaultMessage;
import com.ruoyi.chargingPile.api.query.TChargingGunQuery;
import com.ruoyi.chargingPile.api.vo.GunStatusStatisticsVO;
import com.ruoyi.chargingPile.api.vo.SiteNameVO;
import com.ruoyi.chargingPile.api.vo.TChargingGunVO;
import com.ruoyi.chargingPile.service.ISiteService;
@@ -23,6 +25,7 @@
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.log.enums.OperatorType;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.integration.api.feignClient.IntegrationClient;
import com.ruoyi.integration.api.model.EndCharge;
import com.ruoyi.order.api.feignClient.ChargingOrderClient;
@@ -40,8 +43,10 @@
import java.io.FileReader;
import java.io.PrintWriter;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
 * <p>
@@ -167,7 +172,22 @@
            e.printStackTrace();
        }
    }
    /**
     * 设备状态统计
     */
    @ApiOperation(tags = {"后台-工作台"},value = "设备状态统计")
    @PutMapping(value = "/gunStatusStatistics")
    public AjaxResult<GunStatusStatisticsVO> gunStatusStatistics() {
        List<Integer> siteIds = new ArrayList<>();
        Long userId = SecurityUtils.getUserId();
        //获取当前登录的siteIds
        PageInfo<GetSiteListDTO> siteList1 = siteService.getSiteList1(userId);
        for (GetSiteListDTO datum : siteList1.getRecords()) {
            siteIds.add(datum.getId());
        }
        return AjaxResult.ok(chargingGunService.gunStatusStatistics(siteIds));
    }
    
    /**
     * 根据id获取充电枪完整名称
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TChargingPileController.java
@@ -94,7 +94,12 @@
        return R.ok(chargingPileService.list(Wrappers.lambdaQuery(TChargingPile.class)
                .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")
@@ -161,7 +166,8 @@
        ChargeMonitoring chargeMonitoring = chargingPileService.chargeMonitoring(siteId);
        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;
@@ -24,6 +23,7 @@
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.log.enums.OperatorType;
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;
@@ -34,9 +34,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>
@@ -182,5 +185,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/TChargingGunMapper.java
@@ -3,12 +3,14 @@
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.chargingPile.api.model.TChargingGun;
import com.ruoyi.chargingPile.api.query.TChargingGunQuery;
import com.ruoyi.chargingPile.api.vo.StatusModeStatisticsVO;
import com.ruoyi.chargingPile.api.vo.TChargingGunVO;
import com.ruoyi.common.core.web.page.PageInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
@@ -30,4 +32,18 @@
     */
    List<TChargingGunVO> pageList(@Param("query") TChargingGunQuery query, @Param("pageInfo")PageInfo<TChargingGunVO> pageInfo, @Param("siteIds") Set<Integer> siteIds);
    /**
     * 统计充电枪状态
     * @param siteIds
     * @return
     */
    Map<Integer, Integer> getModeStatistics(@Param("siteIds")List<Integer> siteIds);
    /**
     * 统计充电枪状态
     * @param siteIds
     * @param chargeMode
     * @return
     */
    StatusModeStatisticsVO getStatusModeStatistics(@Param("siteIds")List<Integer> siteIds, @Param("chargeMode")Integer chargeMode);
}
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/TChargingGunService.java
@@ -5,11 +5,13 @@
import com.ruoyi.chargingPile.api.model.TChargingGun;
import com.ruoyi.chargingPile.api.query.TChargingGunQuery;
import com.ruoyi.chargingPile.api.vo.ChargingGunCountVO;
import com.ruoyi.chargingPile.api.vo.GunStatusStatisticsVO;
import com.ruoyi.chargingPile.api.vo.TChargingGunVO;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.PageInfo;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
import java.util.Map;
/**
@@ -50,4 +52,11 @@
     * @return
     */
    Map<String, ChargingGunCountVO> getChargingGunCount(Integer siteId);
    /**
     * 设备状态统计
     * @param siteIds
     * @return
     */
    GunStatusStatisticsVO gunStatusStatistics(List<Integer> siteIds);
}
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/TChargingPileService.java
@@ -89,7 +89,7 @@
     * @return
     */
    ChargeMonitoring chargeMonitoring(Integer siteId);
    
    /**
     * 获取充电枪各种状态汇总
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/TChargingGunServiceImpl.java
@@ -7,9 +7,7 @@
import com.ruoyi.chargingPile.api.model.TChargingGun;
import com.ruoyi.chargingPile.api.model.TChargingPile;
import com.ruoyi.chargingPile.api.query.TChargingGunQuery;
import com.ruoyi.chargingPile.api.vo.ChargingGunCountVO;
import com.ruoyi.chargingPile.api.vo.TChargingGunVO;
import com.ruoyi.chargingPile.api.vo.TMonitoringEquipmentVO;
import com.ruoyi.chargingPile.api.vo.*;
import com.ruoyi.chargingPile.domain.SiteMenu;
import com.ruoyi.chargingPile.mapper.TChargingGunMapper;
import com.ruoyi.chargingPile.service.IPartnerService;
@@ -32,13 +30,8 @@
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.HashSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
import java.util.Set;
/**
 * <p>
@@ -188,6 +181,63 @@
        return map;
    }
    @Override
    public GunStatusStatisticsVO gunStatusStatistics(List<Integer> siteIds) {
        GunStatusStatisticsVO gunStatusStatisticsVO = new GunStatusStatisticsVO();
        if(CollectionUtils.isEmpty(siteIds)){
            Map<Integer, Integer> modeStatisticsNull = new HashMap<>();
            modeStatisticsNull.put(1, 0);
            modeStatisticsNull.put(2, 0);
            modeStatisticsNull.put(3, 0);
            gunStatusStatisticsVO.setModeStatistics(modeStatisticsNull);
            Map<Integer, Integer> statusStatisticsNull = new HashMap<>();
            statusStatisticsNull.put(1, 0);
            statusStatisticsNull.put(2, 0);
            statusStatisticsNull.put(3, 0);
            gunStatusStatisticsVO.setStatusStatistics(statusStatisticsNull);
            List<StatusModeStatisticsVO> statusModeStatistics = new ArrayList<>();
            for (int i = 1; i < 4; i++) {
                StatusModeStatisticsVO statusModeStatisticsVO = new StatusModeStatisticsVO();
                statusModeStatisticsVO.setChargeMode(i);
                statusModeStatisticsVO.setChargingCount(0);
                statusModeStatisticsVO.setFilledCount(0);
                statusModeStatisticsVO.setInsertCount(0);
                statusModeStatisticsVO.setFreeCount(0);
                statusModeStatistics.add(statusModeStatisticsVO);
            }
            gunStatusStatisticsVO.setStatusModeStatistics(statusModeStatistics);
        }
        Map<Integer, Integer> modeStatistics = this.baseMapper.getModeStatistics(siteIds);
        gunStatusStatisticsVO.setModeStatistics(modeStatistics);
        Map<Integer, Integer> statusStatistics = new HashMap<>();
        // 离线
        Long count = this.baseMapper.selectCount(Wrappers.lambdaQuery(TChargingGun.class)
                .eq(TChargingGun::getStatus, 1));
        statusStatistics.put(1, count.intValue());
        // 故障
        count = this.baseMapper.selectCount(Wrappers.lambdaQuery(TChargingGun.class)
                .eq(TChargingGun::getStatus, 7));
        statusStatistics.put(2, count.intValue());
        // 充电中
        count = this.baseMapper.selectCount(Wrappers.lambdaQuery(TChargingGun.class)
                .in(TChargingGun::getStatus, Arrays.asList(3,4,5,6)));
        statusStatistics.put(3, count.intValue());
        gunStatusStatisticsVO.setModeStatistics(statusStatistics);
        List<StatusModeStatisticsVO> statusModeStatisticsVOS = new ArrayList<>();
        StatusModeStatisticsVO statusModeStatistics1 = this.baseMapper.getStatusModeStatistics(siteIds,1);
        StatusModeStatisticsVO statusModeStatistics2 = this.baseMapper.getStatusModeStatistics(siteIds,2);
        StatusModeStatisticsVO statusModeStatistics3 = this.baseMapper.getStatusModeStatistics(siteIds,3);
        statusModeStatisticsVOS.add(statusModeStatistics1);
        statusModeStatisticsVOS.add(statusModeStatistics2);
        statusModeStatisticsVOS.add(statusModeStatistics3);
        gunStatusStatisticsVO.setStatusModeStatistics(statusModeStatisticsVOS);
        return gunStatusStatisticsVO;
    }
    private ChargingGunCountVO getGunCount(Integer chargeMode, List<TChargingGun> list){
        ChargingGunCountVO chargingGunCountVO = new ChargingGunCountVO();
        chargingGunCountVO.setTotalCount(list.stream().filter(tChargingGun -> tChargingGun.getChargeMode().equals(chargeMode)).collect(Collectors.toList()).size());
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingPileServiceImpl.java
@@ -351,7 +351,9 @@
        chargeMonitoring.setUtilizationTrend(utilizationTrend);
        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/TChargingGunMapper.xml
@@ -68,5 +68,35 @@
        </where>
        ORDER BY tcg.create_time DESC
    </select>
    <select id="getModeStatistics" resultType="java.util.Map">
        SELECT
        charge_mode,
        IFNULL(COUNT(charge_mode),0) AS modeCount
        FROM t_charging_gun
        WHERE del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()}
        <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 charge_mode
    </select>
    <select id="getStatusModeStatistics" resultType="com.ruoyi.chargingPile.api.vo.StatusModeStatisticsVO">
        SELECT
        charge_mode,
        IFNULL((SELECT COUNT(*) FROM your_table WHERE status = 2),0) AS freeCount,
        IFNULL((SELECT COUNT(*) FROM your_table WHERE status = 5),0) AS filledCount,
        IFNULL((SELECT COUNT(*) FROM your_table WHERE status = 3),0) AS insertCount,
        IFNULL((SELECT COUNT(*) FROM your_table WHERE status = 4),0) AS chargingCount
        FROM t_charging_gun
        WHERE del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()} AND charge_mode = #{chargeMode}
        <if test="siteIds != null and siteIds.size()>0">
            AND site_id IN
            <foreach collection="siteIds" item="siteId" open="(" separator="," close=")">
                #{siteId}
            </foreach>
        </if>
    </select>
</mapper>
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 &lt;= #{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 &lt;= #{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 &lt;= #{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 &lt;= #{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() {
@@ -849,18 +860,196 @@
        tCharingUserEvaluateVO.setBlackCount(count);
        //好评标签
       List<Map<String,Object>> goodTop = orderEvaluateService.goodTop(siteIds);
       //差评标签
        List<Map<String,Object>> badTop = orderEvaluateService.badTop(siteIds);
        //标签
        //查出好评ids
//        orderEvaluateService.goodTop();
        //流量分析
        List<Map<String,Object>> sourceMap = chargingOrderService.countBySource(siteIds);
        tCharingUserEvaluateVO.setGoodTop(goodTop);
        tCharingUserEvaluateVO.setBadTop(badTop);
        tCharingUserEvaluateVO.setFlow(sourceMap);
        //流量
        return R.ok(tCharingUserEvaluateVO);
    }
    @ResponseBody
    @PostMapping(value = "/charging/equipment")
    @ApiOperation(value = "电站评价", tags = {"管理后台-数据分析-设备运维分析"})
    public R<TCharingUserEquimentVO> equipment(@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<Map<String,Object>> equipmentMap1 = chargingOrderService.equipmentUserType1(siteIds,statisticsQueryDto);
        //交流可用率
        List<Map<String,Object>> equipmentMap2= chargingOrderService.equipmentUserType2(siteIds,statisticsQueryDto);
        //直流故障率
        List<Map<String,Object>> equipmentMapbroke1 = chargingOrderService.equipmentMapbroke1(siteIds,statisticsQueryDto);
        //交流故障率
        List<Map<String,Object>> equipmentMapbroke2 = chargingOrderService.equipmentMapbroke2(siteIds,statisticsQueryDto);
        //直流离网率
        List<Map<String,Object>> equipmentMapOut1 = chargingOrderService.equipmentMapOut1(siteIds,statisticsQueryDto);
        //交流离网率
        List<Map<String,Object>> equipmentMapOut2 = chargingOrderService.equipmentMapOut2(siteIds,statisticsQueryDto);
        //需求电流满足率
        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
@@ -107,4 +107,30 @@
    Long getAver(List<Integer> siteIds);
    List<Map<String, Object>> getLevelEvaluate(List<Integer> siteIds);
    List<Map<String, Object>> countBySource(List<Integer> siteIds);
    List<Map<String, Object>> equipmentUserType1(@Param("siteIds") List<Integer> siteIds, @Param("statisticsQueryDto") ChargingStatisticsQueryDto statisticsQueryDto);
    List<Map<String, Object>> equipmentUserType2(@Param("siteIds")List<Integer> siteIds,@Param("statisticsQueryDto") ChargingStatisticsQueryDto statisticsQueryDto);
    List<Map<String, Object>> equipmentMapbroke1(@Param("siteIds") List<Integer> siteIds, @Param("statisticsQueryDto")ChargingStatisticsQueryDto statisticsQueryDto);
    List<Map<String, Object>> equipmentMapbroke2(@Param("siteIds") List<Integer> siteIds, @Param("statisticsQueryDto")ChargingStatisticsQueryDto statisticsQueryDto);
    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/TOrderEvaluateMapper.java
@@ -49,4 +49,8 @@
     * @return
     */
    List<TOrderEvaluateVO> getOrderEvaluateBySiteId(@Param("siteId")Integer siteId);
    List<Map<String, Object>> goodTop(List<Integer> siteIds);
    List<Map<String, Object>> badTop(List<Integer> siteIds);
}
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
@@ -200,4 +200,30 @@
    PageInfo<TSettlementConfirm> settlementList(SettlementListQuery dto);
    SettlementTotalVO settlementTotal(String time);
    List<Map<String, Object>> countBySource(List<Integer> siteIds);
    List<Map<String, Object>> equipmentUserType1(List<Integer> siteIds, ChargingStatisticsQueryDto statisticsQueryDto);
    List<Map<String, Object>> equipmentUserType2(List<Integer> siteIds, ChargingStatisticsQueryDto statisticsQueryDto);
    List<Map<String, Object>> equipmentMapbroke1(List<Integer> siteIds, ChargingStatisticsQueryDto statisticsQueryDto);
    List<Map<String, Object>> equipmentMapbroke2(List<Integer> siteIds, ChargingStatisticsQueryDto statisticsQueryDto);
    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/TOrderEvaluateService.java
@@ -15,6 +15,7 @@
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
import java.util.Map;
/**
 * <p>
@@ -69,4 +70,8 @@
     * @return
     */
    OrderEvaluateVo getOrderEvaluate(Integer orderId, Integer orderType);
    List<Map<String, Object>> goodTop(List<Integer> siteIds);
    List<Map<String, Object>> badTop(List<Integer> siteIds);
}
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
@@ -2134,6 +2134,71 @@
        return res;
    }
    @Override
    public List<Map<String, Object>> countBySource(List<Integer> siteIds) {
        return this.baseMapper.countBySource(siteIds);
    }
    @Override
    public List<Map<String, Object>> equipmentUserType1(List<Integer> siteIds, ChargingStatisticsQueryDto statisticsQueryDto) {
        return this.baseMapper.equipmentUserType1(siteIds,statisticsQueryDto);
    }
    @Override
    public List<Map<String, Object>> equipmentUserType2(List<Integer> siteIds, ChargingStatisticsQueryDto statisticsQueryDto) {
        return this.baseMapper.equipmentUserType2(siteIds,statisticsQueryDto);
    }
    @Override
    public List<Map<String, Object>> equipmentMapbroke1(List<Integer> siteIds, ChargingStatisticsQueryDto statisticsQueryDto) {
        return this.baseMapper.equipmentMapbroke1(siteIds,statisticsQueryDto);
    }
    @Override
    public List<Map<String, Object>> equipmentMapbroke2(List<Integer> siteIds, ChargingStatisticsQueryDto statisticsQueryDto) {
        return this.baseMapper.equipmentMapbroke2(siteIds,statisticsQueryDto);
    }
    @Override
    public List<Map<String, Object>> equipmentMapOut1(List<Integer> siteIds, ChargingStatisticsQueryDto statisticsQueryDto) {
        return this.baseMapper.equipmentMapOut1(siteIds,statisticsQueryDto);
    }
    @Override
    public List<Map<String, Object>> equipmentMapOut2(List<Integer> siteIds, ChargingStatisticsQueryDto statisticsQueryDto) {
        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/TOrderEvaluateServiceImpl.java
@@ -309,4 +309,14 @@
        }
        return null;
    }
    @Override
    public List<Map<String, Object>> goodTop(List<Integer> siteIds) {
        return this.baseMapper.goodTop(siteIds);
    }
    @Override
    public List<Map<String, Object>> badTop(List<Integer> siteIds) {
        return this.baseMapper.badTop(siteIds);
    }
}
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TShoppingOrderServiceImpl.java
@@ -546,5 +546,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
@@ -862,5 +862,557 @@
            and (t1.end_time between #{endTime1} and #{endTime2})
        </if>
    </select>
    <select id="countBySource" resultType="java.util.Map">
            select
                count(1) as counts,
              source_name as source
            from t_charging_order
            where 1=1
        del_flag = 0
        AND recharge_payment_status = 2
            <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 source_name
    </select>
    <select id="equipmentUserType1" resultType="java.util.Map">
        SELECT
            FORMAT(SUM(TIME_TO_SEC(TIMEDIFF(co.end_time, co.start_time)) /
                       <if test="statisticsQueryDto.dayType == 1">
                           86400
                       </if>
                   <if test="statisticsQueryDto.dayType == 2">
                       604800
                   </if>
                   <if test="statisticsQueryDto.dayType == 3">
                       2592000
                   </if>
                   <if test="statisticsQueryDto.dayType == 4">
                       31536000
                   </if>
                   <if test="statisticsQueryDto.dayType == 5">
                       (86400*(SELECT TIMESTAMPDIFF(DAY, statisticsQueryDto.startTime, statisticsQueryDto.endTime) AS days_difference
                       ))
                   </if>
                   ), 2) AS total_days,co.charging_gun_id,tc.name,cp.name as siteName
        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
            co.start_time IS NOT NULL AND co.end_time IS NOT NULL and cp.type = 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 &lt;= #{statisticsQueryDto.endTime}
            </if>
        </if>
        GROUP BY tc.name,cp.name,co.charging_gun_id
    </select>
    <select id="equipmentUserType2" resultType="java.util.Map">
        SELECT
        FORMAT(SUM(TIME_TO_SEC(TIMEDIFF(co.end_time, co.start_time)) /
        <if test="statisticsQueryDto.dayType == 1">
            86400
        </if>
        <if test="statisticsQueryDto.dayType == 2">
            604800
        </if>
        <if test="statisticsQueryDto.dayType == 3">
            2592000
        </if>
        <if test="statisticsQueryDto.dayType == 4">
            31536000
        </if>
        <if test="statisticsQueryDto.dayType == 5">
            (86400*(SELECT TIMESTAMPDIFF(DAY, statisticsQueryDto.startTime, statisticsQueryDto.endTime) AS days_difference
            ))
        </if>
        ), 2) AS total_days,co.charging_gun_id,tc.name,cp.name as siteName
        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
        co.start_time IS NOT NULL AND co.end_time IS NOT NULL and cp.type = 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 &lt;= #{statisticsQueryDto.endTime}
            </if>
        </if>
        GROUP BY tc.name,cp.name,co.charging_gun_id
    </select>
    <select id="equipmentMapbroke1" resultType="java.util.Map">
        SELECT
            FORMAT(SUM(TIME_TO_SEC(TIMEDIFF(co.end_time, co.down_time)) /
        <if test="statisticsQueryDto.dayType == 1">
            86400
        </if>
        <if test="statisticsQueryDto.dayType == 2">
            604800
        </if>
        <if test="statisticsQueryDto.dayType == 3">
            2592000
        </if>
        <if test="statisticsQueryDto.dayType == 4">
            31536000
        </if>
        <if test="statisticsQueryDto.dayType == 5">
            (86400*(SELECT TIMESTAMPDIFF(DAY, statisticsQueryDto.startTime, statisticsQueryDto.endTime) AS days_difference
            ))
        </if>
                   ), 2) AS total_days,co.charging_gun_id,tc.name,cp.name as name1
        FROM
            `charging_pile_service`.`t_fault_message` 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
            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 &lt;= #{statisticsQueryDto.endTime}
            </if>
        </if>
        GROUP BY tc.name,cp.name,co.charging_gun_id
    </select>
    <select id="equipmentMapbroke2" resultType="java.util.Map">
        SELECT
        FORMAT(SUM(TIME_TO_SEC(TIMEDIFF(co.end_time, co.down_time)) /
        <if test="statisticsQueryDto.dayType == 1">
            86400
        </if>
        <if test="statisticsQueryDto.dayType == 2">
            604800
        </if>
        <if test="statisticsQueryDto.dayType == 3">
            2592000
        </if>
        <if test="statisticsQueryDto.dayType == 4">
            31536000
        </if>
        <if test="statisticsQueryDto.dayType == 5">
            (86400*(SELECT TIMESTAMPDIFF(DAY, statisticsQueryDto.startTime, statisticsQueryDto.endTime) AS days_difference
            ))
        </if>
        ), 2) AS total_days,co.charging_gun_id,tc.name,cp.name as name1
        FROM
        `charging_pile_service`.`t_fault_message` 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
        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 &lt;= #{statisticsQueryDto.endTime}
            </if>
        </if>
        GROUP BY tc.name,cp.name,co.charging_gun_id
    </select>
    <select id="equipmentMapOut1" resultType="java.util.Map">
        SELECT
        FORMAT(SUM(TIME_TO_SEC(TIMEDIFF(co.end_time, co.down_time)) /
        <if test="statisticsQueryDto.dayType == 1">
            86400
        </if>
        <if test="statisticsQueryDto.dayType == 2">
            604800
        </if>
        <if test="statisticsQueryDto.dayType == 3">
            2592000
        </if>
        <if test="statisticsQueryDto.dayType == 4">
            31536000
        </if>
        <if test="statisticsQueryDto.dayType == 5">
            (86400*(SELECT TIMESTAMPDIFF(DAY, statisticsQueryDto.startTime, statisticsQueryDto.endTime) AS days_difference
            ))
        </if>
        ), 2) AS total_days,co.charging_gun_id,tc.name,cp.name as name1
        FROM
        `charging_pile_service`.`t_fault_message` 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
        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 &lt;= #{statisticsQueryDto.endTime}
            </if>
        </if>
        GROUP BY tc.name,cp.name,co.charging_gun_id
    </select>
    <select id="equipmentMapOut2" resultType="java.util.Map">
        SELECT
        FORMAT(SUM(TIME_TO_SEC(TIMEDIFF(co.end_time, co.down_time)) /
        <if test="statisticsQueryDto.dayType == 1">
            86400
        </if>
        <if test="statisticsQueryDto.dayType == 2">
            604800
        </if>
        <if test="statisticsQueryDto.dayType == 3">
            2592000
        </if>
        <if test="statisticsQueryDto.dayType == 4">
            31536000
        </if>
        <if test="statisticsQueryDto.dayType == 5">
            (86400*(SELECT TIMESTAMPDIFF(DAY, statisticsQueryDto.startTime, statisticsQueryDto.endTime) AS days_difference
            ))
        </if>
        ), 2) AS total_days,co.charging_gun_id,tc.name,cp.name as name1
        FROM
        `charging_pile_service`.`t_fault_message` 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
        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 &lt;= #{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 &lt;= #{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/TOrderEvaluateMapper.xml
@@ -124,4 +124,41 @@
        </if>
        order by a.create_time desc
    </select>
    <select id="goodTop" resultType="java.util.Map">
        SELECT count(1) as counts ,ot.evaluation_tag_id
        from t_order_evaluate_tag ot
                 left join t_order_evaluate te on ot.order_evaluate_id = te.id
                 left join t_charging_order co on te.order_id = co.id
        WHERE ot.evaluation_tag_id in (
            SELECT id from `charging_pile_other`.`t_evaluation_tag` WHERE type = 1
        ) <if test="null != siteIds">
            and co.site_id in
            <foreach collection="siteIds" item="item" index="index" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        GROUP BY ot.evaluation_tag_id
        ORDER BY counts desc
            limit 5
    </select>
    <select id="badTop" resultType="java.util.Map">
        SELECT count(1) as counts ,ot.evaluation_tag_id
        from t_order_evaluate_tag ot
        left join t_order_evaluate te on ot.order_evaluate_id = te.id
        left join t_charging_order co on te.order_id = co.id
        WHERE ot.evaluation_tag_id in (
        SELECT id from `charging_pile_other`.`t_evaluation_tag` WHERE type = 3
        ) <if test="null != siteIds">
        and co.site_id in
        <foreach collection="siteIds" item="item" index="index" open="(" separator="," close=")">
            #{item}
        </foreach>
    </if>
        GROUP BY ot.evaluation_tag_id
        ORDER BY counts desc
        limit 5
    </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') &gt;= 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/TCouponController.java
@@ -127,6 +127,8 @@
                record.setDetailsPicture(byId.getDetailsPicture());
            }
        }
        PageInfo<ExchangeRecordVO> exchangeRecordVOPageInfo = new PageInfo<>(1, 99999999);
        exchangeRecordVOPageInfo.setRecords(data);
        return AjaxResult.ok(data);
    }
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TGoodsController.java
@@ -190,6 +190,7 @@
        //检查当前用户积分是否够
        Long userId = tokenService.getLoginUserApplet().getUserId();
        Integer point = 0;
        TAppUser user = appUserClient.getUserById(userId).getData();
        if (exchangeDto.getGoodType()==1) {
            //查询当前商品信息
@@ -200,7 +201,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("当前用户积分不足");
             }
@@ -212,6 +212,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);