| | |
| | | import com.ruoyi.chargingPile.api.vo.*; |
| | | import com.ruoyi.chargingPile.dto.SiteDTO; |
| | | import com.ruoyi.chargingPile.service.*; |
| | | import com.ruoyi.chargingPile.vo.SiteDetailInfoVO; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.dto.ChargingOrderGroup; |
| | | import com.ruoyi.common.core.dto.ChargingPercentBack; |
| | | import com.ruoyi.common.core.dto.ChargingPercentProvinceDto; |
| | | import com.ruoyi.common.core.utils.DateUtils; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.common.log.annotation.Log; |
| | | import com.ruoyi.common.log.enums.BusinessType; |
| | | import com.ruoyi.common.security.annotation.Logical; |
| | | import com.ruoyi.common.security.annotation.RequiresPermissions; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.order.feignClient.ChargingOrderClient; |
| | | import com.ruoyi.order.feignClient.OrderClient; |
| | | import com.ruoyi.order.model.ChargeOrder; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import com.ruoyi.system.api.model.SysUserRoleVo; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import org.apache.poi.ss.formula.functions.T; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalTime; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | |
| | | private TAccountingStrategyService accountingStrategyService; |
| | | @Autowired |
| | | private TAccountingStrategyDetailService accountingStrategyDetailService; |
| | | @Resource |
| | | private OrderClient orderClient; |
| | | @Resource |
| | | private ChargingOrderClient chargingOrderClient; |
| | | @Resource |
| | | private TokenService tokenService; |
| | | @Resource |
| | | private SysUserClient sysUserClient; |
| | | |
| | | @GetMapping("/map/getSiteList") |
| | | @ApiOperation(value = "获取站点", tags = {"2.0-管理后台-数据分析-电站分布"}) |
| | | public R<List<GetSiteListDTO>> getMapSiteList(GetSiteList siteList){ |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | SysUser data = sysUserClient.getSysUser(userid).getData(); |
| | | |
| | | if (data.getRoleType()==2){ |
| | | siteList.setSiteId(data.getSiteId()); |
| | | } |
| | | List<GetSiteListDTO> list = siteService.getSiteListNolimit(siteList); |
| | | List<GetSiteListDTO> records = list; |
| | | |
| | | for (GetSiteListDTO record : records) { |
| | | List<Integer> c1 = new ArrayList<>(); |
| | | c1.add(3); |
| | | c1.add(4); |
| | | c1.add(5); |
| | | c1.add(6); |
| | | Long count = chargingGunService.lambdaQuery().eq(TChargingGun::getSiteId, record.getId()).eq(TChargingGun::getChargeMode, 1).eq(TChargingGun::getStatus, 2).count(); |
| | | record.setC1(count); |
| | | Long count1 = chargingGunService.lambdaQuery().eq(TChargingGun::getSiteId, record.getId()).eq(TChargingGun::getChargeMode, 1).count(); |
| | | record.setC2(count1); |
| | | Long count2 = chargingGunService.lambdaQuery().eq(TChargingGun::getSiteId, record.getId()).eq(TChargingGun::getChargeMode, 2).eq(TChargingGun::getStatus, 2).count(); |
| | | record.setK1(count2); |
| | | Long count3 = chargingGunService.lambdaQuery().eq(TChargingGun::getSiteId, record.getId()).eq(TChargingGun::getChargeMode, 2).count(); |
| | | record.setK2(count3); |
| | | Long count4 = chargingGunService.lambdaQuery().eq(TChargingGun::getSiteId, record.getId()).eq(TChargingGun::getChargeMode, 3).eq(TChargingGun::getStatus, 2).count(); |
| | | record.setM1(count4); |
| | | Long count5 = chargingGunService.lambdaQuery().eq(TChargingGun::getSiteId, record.getId()).eq(TChargingGun::getChargeMode, 3).count(); |
| | | record.setM2(count5); |
| | | |
| | | //利用率 |
| | | BigDecimal bigDecimal = new BigDecimal("0"); |
| | | //获取该站点的总充电度数 |
| | | List<ChargeOrder> chargingOrders = orderClient.getList(record.getId()).getData(); |
| | | for (ChargeOrder chargingOrder : chargingOrders) { |
| | | bigDecimal = bigDecimal.add(chargingOrder.getChargingCapacity()); |
| | | } |
| | | //获取该站点的所有充电桩 |
| | | List<TChargingPile> chargingPiles = chargingPileService.lambdaQuery().eq(TChargingPile::getSiteId, record.getId()).list(); |
| | | BigDecimal bigDecimal1 = new BigDecimal("0"); |
| | | for (TChargingPile chargingPile : chargingPiles) { |
| | | bigDecimal1 = bigDecimal1.add(chargingPile.getRatedPower()); |
| | | } |
| | | BigDecimal multiply = bigDecimal1.multiply(new BigDecimal("24")); |
| | | if (multiply.compareTo(BigDecimal.ZERO)==0){ |
| | | record.setP1(BigDecimal.ZERO); |
| | | }else{ |
| | | BigDecimal divide = bigDecimal.divide(multiply, 4, BigDecimal.ROUND_HALF_EVEN).multiply(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_EVEN); |
| | | record.setP1(divide); |
| | | |
| | | } |
| | | |
| | | } |
| | | return R.ok(records); |
| | | } |
| | | |
| | | /** |
| | | * 根据站点id 查询所有充电桩 |
| | |
| | | int isLogin = StringUtils.isEmpty(SecurityUtils.getToken(request)) ? 0 : 1; |
| | | return AjaxResult.success(siteService.pageList(query,isLogin)); |
| | | } |
| | | |
| | | // @RequiresPermissions(value = {"/chargeDistribution"}, logical = Logical.OR) |
| | | @PostMapping("/map/getPercentByprovinceCode") |
| | | @ApiOperation(value = "获取该充电站的利用率", tags = {"管理后台-数据分析-电站分析"}) |
| | | public R getPercentByCityCode(@RequestBody ChargingPercentProvinceDto chargingPercentProvinceDto){ |
| | | Set<Integer> ids = null; |
| | | chargingPercentProvinceDto.setSiteIds(ids); |
| | | 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获取各个充电站的充电订单 |
| | | if (chargingPercentProvinceDto.getDate1().equals(chargingPercentProvinceDto.getDate2())){ |
| | | chargingPercentProvinceDto.setDate2(chargingPercentProvinceDto.getDate1().plusDays(1)); |
| | | } |
| | | 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()); |
| | | 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); |
| | | } |
| | | @ApiOperation(value = "获取站点详细信息", tags = {"小程序-站点管理-站点详情"}) |
| | | @PostMapping("/getDetailById") |
| | | public AjaxResult<SiteDetailVO> getDetailById(@Validated @RequestBody SiteDetailQuery query){ |
| | |
| | | @ResponseBody |
| | | @PostMapping("/getSiteInfo/{id}") |
| | | @ApiOperation(value = "获取站点详情", tags = {"管理后台-站点管理"}) |
| | | public AjaxResult<Site> getSiteInfo(@PathVariable Integer id){ |
| | | public R<SiteDetailInfoVO> getSiteInfo(@PathVariable Integer id){ |
| | | SiteDetailInfoVO res = new SiteDetailInfoVO(); |
| | | Site site = siteService.getById(id); |
| | | return AjaxResult.success(site); |
| | | SysUser data = sysUserClient.getSysUser(site.getUserId()).getData(); |
| | | if (data!=null){ |
| | | res.setAccount(data.getUserName()); |
| | | res.setPassword("********"); |
| | | } |
| | | BeanUtils.copyProperties(site, res); |
| | | return R.ok(res); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/editSite") |
| | | @ApiOperation(value = "编辑站点", tags = {"管理后台-站点管理"}) |