| | |
| | | import com.ruoyi.chargingPile.api.query.SiteQuery; |
| | | import com.ruoyi.chargingPile.api.vo.*; |
| | | import com.ruoyi.chargingPile.domain.SiteMenu; |
| | | import com.ruoyi.chargingPile.dto.ChargingPercentBack; |
| | | import com.ruoyi.common.core.dto.ChargingOrderGroup; |
| | | import com.ruoyi.common.core.dto.ChargingPercentProvinceDto; |
| | | import com.ruoyi.chargingPile.service.*; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.utils.GeodesyUtil; |
| | |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.order.api.feignClient.ChargingOrderClient; |
| | | import com.ruoyi.order.api.model.TChargingOrder; |
| | | import com.ruoyi.other.api.feignClient.RoleSiteClient; |
| | | import com.ruoyi.other.api.feignClient.UserSiteClient; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalTime; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | |
| | | @Autowired |
| | | private TAccountingStrategyDetailService accountingStrategyDetailService; |
| | | |
| | | @Resource |
| | | private ChargingOrderClient chargingOrderClient; |
| | | |
| | | |
| | | /** |
| | | * 小程序扫一扫 |
| | |
| | | PageInfo<GetSiteListDTO> list = siteService.getSiteList(siteList); |
| | | return AjaxResult.success(list); |
| | | } |
| | | @GetMapping("/getSiteList/byUserId") |
| | | @ApiOperation(value = "获取站点列表", tags = {"管理后台-站点管理"}) |
| | | public R<List<GetSiteListDTO>> getSiteListByUserId(@RequestParam("userId") Long userId){ |
| | | PageInfo<GetSiteListDTO> list = siteService.getSiteList1(userId); |
| | | return R.ok(list.getRecords()); |
| | | } |
| | | |
| | | |
| | | |
| | | @GetMapping("/map/getSiteList") |
| | | @ApiOperation(value = "获取站点", tags = {"管理后台-数据分析-电站分析"}) |
| | | public R<List<GetSiteListDTO>> getMapSiteList(GetSiteList siteList){ |
| | | siteList.setPageCurr(1); |
| | | siteList.setPageCurr(99999); |
| | | PageInfo<GetSiteListDTO> list = siteService.getSiteList(siteList); |
| | | return R.ok(list.getRecords()); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/map/getPercent") |
| | | @ApiOperation(value = "获取该充电站的利用率", tags = {"管理后台-数据分析-电站分析"}) |
| | | public R getPercent(Integer siteId){ |
| | | BigDecimal bigDecimal = new BigDecimal("0"); |
| | | //获取该站点的总充电度数 |
| | | List<TChargingOrder> chargingOrders = chargingOrderClient.getList(siteId).getData(); |
| | | for (TChargingOrder chargingOrder : chargingOrders) { |
| | | bigDecimal = bigDecimal.add(chargingOrder.getChargingCapacity()); |
| | | } |
| | | //获取该站点的所有充电桩 |
| | | List<TChargingPile> chargingPiles = chargingPileService.lambdaQuery().eq(TChargingPile::getSiteId, siteId).list(); |
| | | BigDecimal bigDecimal1 = new BigDecimal("0"); |
| | | for (TChargingPile chargingPile : chargingPiles) { |
| | | bigDecimal1 = bigDecimal1.add(chargingPile.getRatedPower()); |
| | | } |
| | | BigDecimal multiply = bigDecimal1.multiply(new BigDecimal("24")); |
| | | |
| | | BigDecimal divide = bigDecimal.divide(multiply, 0, BigDecimal.ROUND_HALF_UP); |
| | | |
| | | |
| | | return R.ok(divide); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @PostMapping("/map/getPercentByprovinceCode") |
| | | @ApiOperation(value = "获取该充电站的利用率", tags = {"管理后台-数据分析-电站分析"}) |
| | | public R getPercentByCityCode(@RequestBody ChargingPercentProvinceDto chargingPercentProvinceDto){ |
| | | |
| | | if (chargingPercentProvinceDto.getDate1()==null){ |
| | | LocalDate today = LocalDate.now(); |
| | | LocalDate lastMonth = today.minusMonths(1); |
| | | LocalDate firstDayOfLastMonth = lastMonth.withDayOfMonth(1); |
| | | LocalDate lastDayOfLastMonth =lastMonth.withDayOfMonth(lastMonth.lengthOfMonth()); |
| | | chargingPercentProvinceDto.setDate1(firstDayOfLastMonth); |
| | | chargingPercentProvinceDto.setDate2(lastDayOfLastMonth); |
| | | } |
| | | |
| | | |
| | | |
| | | GetSiteList siteList = new GetSiteList(); |
| | | siteList.setProvinceCode(chargingPercentProvinceDto.getProvinceCode()); |
| | | siteList.setPageCurr(1); |
| | | siteList.setPageCurr(9999); |
| | | ChargingPercentBack chargingPercentBack = new ChargingPercentBack(); |
| | | |
| | | //通过省编码获取充电站id |
| | | List<GetSiteListDTO> records = siteService.getSiteList(siteList).getRecords(); |
| | | List<Integer> collect = records.stream().map(GetSiteListDTO::getId).collect(Collectors.toList()); |
| | | // 通过时间段获取和充电桩id获取各个充电站的充电订单 |
| | | List<ChargingOrderGroup> data = chargingOrderClient.getBySiteIdAndTime(chargingPercentProvinceDto).getData(); |
| | | // 计算利用率展示 |
| | | for (ChargingOrderGroup datum : data) { |
| | | List<TChargingPile> chargingPiles = chargingPileService.lambdaQuery().eq(TChargingPile::getSiteId, datum.getSiteId()).list(); |
| | | BigDecimal bigDecimal1 = new BigDecimal("0"); |
| | | for (TChargingPile chargingPile : chargingPiles) { |
| | | bigDecimal1 = bigDecimal1.add(chargingPile.getRatedPower()); |
| | | } |
| | | |
| | | long daysBetween = ChronoUnit.DAYS.between(chargingPercentProvinceDto.getDate1(), chargingPercentProvinceDto.getDate2()) + 1; |
| | | BigDecimal multiply = bigDecimal1.multiply(new BigDecimal("24")).multiply(BigDecimal.valueOf(daysBetween)); |
| | | //得到利用率 |
| | | BigDecimal divide = datum.getChargingCapacity().divide(multiply, 0, BigDecimal.ROUND_HALF_UP); |
| | | //如果利用率大于等于10 |
| | | if (divide.compareTo(BigDecimal.valueOf(10))>=0){ |
| | | chargingPercentBack.setCount1(chargingPercentBack.getCount1()+1); |
| | | } |
| | | |
| | | //如果利用率大于等于5小于10 |
| | | if (divide.compareTo(BigDecimal.valueOf(5))>=0 && divide.compareTo(BigDecimal.valueOf(10))<0){ |
| | | chargingPercentBack.setCount2(chargingPercentBack.getCount2()+1); |
| | | } |
| | | //如果利用率大于等于1小于5 |
| | | if (divide.compareTo(BigDecimal.valueOf(1))>=0 && divide.compareTo(BigDecimal.valueOf(5))<0){ |
| | | chargingPercentBack.setCount3(chargingPercentBack.getCount3()+1); |
| | | } |
| | | //如果利用率小于1 |
| | | if (divide.compareTo(BigDecimal.valueOf(1))<0){ |
| | | chargingPercentBack.setCount4(chargingPercentBack.getCount4()+1); |
| | | } |
| | | |
| | | } |
| | | return R.ok(chargingPercentBack); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/getSiteList1") |
| | | @ApiOperation(value = "获取站点列表 不分页", tags = {"管理后台-活动费用统计"}) |
| | | public AjaxResult<List<Site>> getSiteList1(){ |
| | |
| | | return AjaxResult.success(chargingPileService.getChargingGunList(siteId,type)); |
| | | } |
| | | |
| | | @ApiOperation(value = "获取站点下充电枪数量统计", tags = {"小程序-站点管理-站点详情"}) |
| | | @ApiOperation(value = "获取站点下充电枪数量统计", tags = {"小程序-站点管理-站点详情","管理后台-数据分析-电站分析"}) |
| | | @GetMapping("/getChargingGunCount") |
| | | public AjaxResult<Map<String,ChargingGunCountVO>> getChargingGunCount(@RequestParam(value = "siteId")@ApiParam(value = "站点id", required = true)Integer siteId){ |
| | | return AjaxResult.success(chargingGunService.getChargingGunCount(siteId)); |