| | |
| | | import com.ruoyi.chargingPile.api.vo.*; |
| | | import com.ruoyi.chargingPile.api.domain.SiteMenu; |
| | | import com.ruoyi.chargingPile.dto.ChargingPercentBack; |
| | | import com.ruoyi.chargingPile.dto.BatchSetSiteAccountingStrategyDTO; |
| | | import com.ruoyi.chargingPile.dto.SiteExcelDTO; |
| | | import com.ruoyi.chargingPile.dto.SiteImportResultDTO; |
| | | 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.DateUtils; |
| | | import com.ruoyi.common.core.utils.ServletUtils; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.utils.poi.ExcelUtil; |
| | | 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.log.enums.OperatorType; |
| | | import com.ruoyi.common.security.annotation.Logical; |
| | | import com.ruoyi.common.security.annotation.RequiresPermissions; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalTime; |
| | | import java.time.temporal.ChronoUnit; |
| | |
| | | private AppUserClient appUserClient; |
| | | @Resource |
| | | private AppUserVipDetailClient vipDetailClient; |
| | | |
| | | // 远程新增临时站点 |
| | | @ResponseBody |
| | | @PostMapping("/addSiteTemp") |
| | | @ApiOperation(value = "添加站点", tags = {"管理后台-站点管理"}) |
| | | @Log(title = "【站点管理】添加站点", businessType = BusinessType.INSERT) |
| | | public R addSiteTemp(@RequestBody Site site){ |
| | | siteService.save(site); |
| | | return R.ok(site.getId()); |
| | | } |
| | | /** |
| | | * 根据站点id 查询所有充电桩 |
| | | * @param siteId |
| | |
| | | * @param number |
| | | * @return |
| | | */ |
| | | @Log(title = "【扫一扫】通过桩编号获取电站信息", businessType = BusinessType.OTHER,operatorType = OperatorType.MOBILE) |
| | | @GetMapping("/getSiteInfoByNumber") |
| | | @ApiOperation(value = "扫一扫后通过桩编号获取电站信息", tags = {"小程序-扫一扫"}) |
| | | public R<SiteInfoVO> getSiteInfoByNumber(@RequestParam("number") String number){ |
| | | SiteInfoVO siteInfoVO = new SiteInfoVO(); |
| | | TChargingGun chargingGun = chargingGunService.getOne(new LambdaQueryWrapper<TChargingGun>().eq(TChargingGun::getFullNumber, number)); |
| | | Site site = siteService.getById(chargingGun.getSiteId()); |
| | | siteInfoVO.setMemberDiscountFlag(site.getMemberDiscountFlag()); |
| | | Integer accountingStrategyId = chargingGun.getAccountingStrategyId(); |
| | | if(null == accountingStrategyId){ |
| | | accountingStrategyId = site.getAccountingStrategyId(); |
| | | } |
| | | TChargingPile one = chargingPileService.getById(chargingGun.getChargingPileId()); |
| | | Site byId = siteService.getById(chargingGun.getSiteId()); |
| | | TAccountingStrategy byId1 = accountingStrategyService.getById(chargingGun.getAccountingStrategyId()); |
| | | TAccountingStrategy byId1 = accountingStrategyService.getById(accountingStrategyId); |
| | | List<TAccountingStrategyDetail> list = accountingStrategyDetailService.lambdaQuery().eq(TAccountingStrategyDetail::getAccountingStrategyId, byId1.getId()).list(); |
| | | list.stream().filter(item -> "00:00".equals(item.getEndTime())).forEach(item -> item.setEndTime("23:59:59")); |
| | | for (TAccountingStrategyDetail tAccountingStrategyDetail : list) { |
| | |
| | | if(DateUtils.string2LocalTime(tAccountingStrategyDetail.getStartTime() + ":00").compareTo(LocalTime.now()) <= 0 |
| | | && DateUtils.string2LocalTime(tAccountingStrategyDetail.getEndTime() + ("23:59:59".equals(tAccountingStrategyDetail.getEndTime())?"":":00")).compareTo(LocalTime.now()) > 0){ |
| | | siteInfoVO.setElectrovalence(tAccountingStrategyDetail.getElectrovalence().add(tAccountingStrategyDetail.getServiceCharge()).setScale(4, BigDecimal.ROUND_HALF_UP)); |
| | | siteInfoVO.setVipElectrovalence(siteInfoVO.getElectrovalence()); |
| | | // 获取当前登录用户id |
| | | Long userId = tokenService.getLoginUserApplet().getUserId(); |
| | | // 根据id查询用户信息 |
| | | TAppUser appUser = appUserClient.getUserById(userId).getData(); |
| | | if(Objects.nonNull(byId1.getDiscount())){ |
| | | siteInfoVO.setVipElectrovalence((tAccountingStrategyDetail.getServiceCharge().multiply(byId1.getDiscount()).add(tAccountingStrategyDetail.getElectrovalence())).setScale(4, BigDecimal.ROUND_HALF_UP)); |
| | | }else { |
| | | siteInfoVO.setVipElectrovalence((tAccountingStrategyDetail.getServiceCharge().add(tAccountingStrategyDetail.getElectrovalence())).setScale(4, BigDecimal.ROUND_HALF_UP)); |
| | | } |
| | | if(Objects.nonNull(appUser)){ |
| | | String token = SecurityUtils.getToken(ServletUtils.getRequest()); |
| | | if(Integer.valueOf(1).equals(site.getMemberDiscountFlag()) && StringUtils.isNotEmpty(token)){ |
| | | Long userId = tokenService.getLoginUserApplet().getUserId(); |
| | | // 根据id查询用户信息 |
| | | TAppUser appUser = appUserClient.getUserById(userId).getData(); |
| | | if(Objects.nonNull(byId1.getDiscount())){ |
| | | siteInfoVO.setVipElectrovalence((tAccountingStrategyDetail.getServiceCharge().multiply(byId1.getDiscount()).add(tAccountingStrategyDetail.getElectrovalence())).setScale(4, BigDecimal.ROUND_HALF_UP)); |
| | | }else { |
| | | siteInfoVO.setVipElectrovalence((tAccountingStrategyDetail.getServiceCharge().add(tAccountingStrategyDetail.getElectrovalence())).setScale(4, BigDecimal.ROUND_HALF_UP)); |
| | | } |
| | | TVip vip = null; |
| | | if(Objects.nonNull(appUser)){ |
| | | // TVip vip = vipClient.getInfo1(appUser.getVipId()).getData(); |
| | | GetAppUserVipDetail getAppUserVipDetail = new GetAppUserVipDetail(); |
| | | getAppUserVipDetail.setAppUserId(userId); |
| | | getAppUserVipDetail.setVipId(appUser.getVipId()); |
| | | R<TAppUserVipDetail> appUserVipDetail = vipDetailClient.getAppUserVipDetail(getAppUserVipDetail); |
| | | TAppUserVipDetail data1 = appUserVipDetail.getData(); |
| | | if(Objects.nonNull(data1)){ |
| | | String vipJson = data1.getVipJson(); |
| | | TVip vip = JSON.parseObject(vipJson, TVip.class); |
| | | if(Objects.nonNull(vip) && vip.getType() == 2){ |
| | | siteInfoVO.setVipElectrovalence(vip.getDiscount().divide(new BigDecimal(10)).multiply(tAccountingStrategyDetail.getServiceCharge()).add(tAccountingStrategyDetail.getElectrovalence())); |
| | | GetAppUserVipDetail getAppUserVipDetail = new GetAppUserVipDetail(); |
| | | getAppUserVipDetail.setAppUserId(userId); |
| | | getAppUserVipDetail.setVipId(appUser.getVipId()); |
| | | R<TAppUserVipDetail> appUserVipDetail = vipDetailClient.getAppUserVipDetail(getAppUserVipDetail); |
| | | TAppUserVipDetail data1 = appUserVipDetail.getData(); |
| | | if(Objects.nonNull(data1)){ |
| | | String vipJson = data1.getVipJson(); |
| | | vip = JSON.parseObject(vipJson, TVip.class); |
| | | } |
| | | } |
| | | |
| | | if(Objects.nonNull(vip) && vip.getType() == 2){ |
| | | siteInfoVO.setVipElectrovalence(vip.getDiscount().divide(new BigDecimal(10)).multiply(tAccountingStrategyDetail.getServiceCharge()).add(tAccountingStrategyDetail.getElectrovalence())); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | siteInfoVO.setChargingGunId(chargingGun.getId()); |
| | | siteInfoVO.setChargingPileId(one.getId()); |
| | | siteInfoVO.setName(byId.getName()); |
| | | siteInfoVO.setName(site.getName()); |
| | | siteInfoVO.setNumber(one.getNumber().toString()); |
| | | siteInfoVO.setSpaceChargeExplain(byId.getSpaceChargeExplain()); |
| | | siteInfoVO.setSpaceChargeExplain(site.getSpaceChargeExplain()); |
| | | siteInfoVO.setSupportOrder(site.getSupportOrder()); |
| | | siteInfoVO.setReservationStartTime(site.getReservationStartTime()); |
| | | siteInfoVO.setReservationEndTime(site.getReservationEndTime()); |
| | | siteInfoVO.setVinFlag(one.getVinFlag()); |
| | | return R.ok(siteInfoVO); |
| | | } |
| | | /** |
| | |
| | | public R<SiteInfoVO> getSiteInfoByNumber1(@RequestParam("number") String number){ |
| | | SiteInfoVO siteInfoVO = new SiteInfoVO(); |
| | | TChargingPile one = chargingPileService.lambdaQuery().eq(TChargingPile::getCode, number).one(); |
| | | Site byId = siteService.getById(one.getSiteId()); |
| | | TAccountingStrategy byId1 = accountingStrategyService.getById(byId.getAccountingStrategyId()); |
| | | TChargingGun chargingGun = chargingGunService.getOne(new LambdaQueryWrapper<TChargingGun>().eq(TChargingGun::getChargingPileId, one.getId()).last(" limit 0, 1")); |
| | | Site site = siteService.getById(chargingGun.getSiteId()); |
| | | siteInfoVO.setMemberDiscountFlag(site.getMemberDiscountFlag()); |
| | | Integer accountingStrategyId = chargingGun.getAccountingStrategyId(); |
| | | if(null == accountingStrategyId){ |
| | | accountingStrategyId = site.getAccountingStrategyId(); |
| | | } |
| | | TAccountingStrategy byId1 = accountingStrategyService.getById(accountingStrategyId); |
| | | List<TAccountingStrategyDetail> list = accountingStrategyDetailService.lambdaQuery().eq(TAccountingStrategyDetail::getAccountingStrategyId, byId1.getId()).list(); |
| | | list.stream().filter(item -> "00:00".equals(item.getEndTime())).forEach(item -> item.setEndTime("23:59:59")); |
| | | for (TAccountingStrategyDetail tAccountingStrategyDetail : list) { |
| | |
| | | if(DateUtils.string2LocalTime(tAccountingStrategyDetail.getStartTime() + ":00").compareTo(LocalTime.now()) <= 0 |
| | | && DateUtils.string2LocalTime(tAccountingStrategyDetail.getEndTime() + ("23:59:59".equals(tAccountingStrategyDetail.getEndTime())?"":":00")).compareTo(LocalTime.now()) > 0){ |
| | | siteInfoVO.setElectrovalence(tAccountingStrategyDetail.getElectrovalence().add(tAccountingStrategyDetail.getServiceCharge()).setScale(4, BigDecimal.ROUND_HALF_UP)); |
| | | siteInfoVO.setVipElectrovalence(siteInfoVO.getElectrovalence()); |
| | | // 获取当前登录用户id |
| | | Long userId = tokenService.getLoginUserApplet().getUserId(); |
| | | // 根据id查询用户信息 |
| | | TAppUser appUser = appUserClient.getUserById(userId).getData(); |
| | | if(Objects.nonNull(byId1.getDiscount())){ |
| | | String token = SecurityUtils.getToken(ServletUtils.getRequest()); |
| | | if(Integer.valueOf(1).equals(site.getMemberDiscountFlag()) && StringUtils.isNotEmpty(token)){ |
| | | Long userId = tokenService.getLoginUserApplet().getUserId(); |
| | | // 根据id查询用户信息 |
| | | TAppUser appUser = appUserClient.getUserById(userId).getData(); |
| | | if(Objects.nonNull(appUser)){ |
| | | // TVip vip = vipClient.getInfo1(appUser.getVipId()).getData(); |
| | | GetAppUserVipDetail getAppUserVipDetail = new GetAppUserVipDetail(); |
| | | getAppUserVipDetail.setAppUserId(userId); |
| | | getAppUserVipDetail.setVipId(appUser.getVipId()); |
| | | R<TAppUserVipDetail> appUserVipDetail = vipDetailClient.getAppUserVipDetail(getAppUserVipDetail); |
| | | TAppUserVipDetail data1 = appUserVipDetail.getData(); |
| | | if(Objects.nonNull(data1)){ |
| | | String vipJson = data1.getVipJson(); |
| | | TVip vip = JSON.parseObject(vipJson, TVip.class); |
| | | if(Objects.nonNull(vip) && vip.getType() == 2){ |
| | | siteInfoVO.setVipElectrovalence(vip.getDiscount().divide(new BigDecimal(10)).multiply(tAccountingStrategyDetail.getServiceCharge()).add(tAccountingStrategyDetail.getElectrovalence())); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | if(Integer.valueOf(1).equals(site.getMemberDiscountFlag()) && Objects.nonNull(byId1.getDiscount())){ |
| | | siteInfoVO.setVipElectrovalence((tAccountingStrategyDetail.getServiceCharge().multiply(byId1.getDiscount()).add(tAccountingStrategyDetail.getElectrovalence())).setScale(4, BigDecimal.ROUND_HALF_UP)); |
| | | }else { |
| | | siteInfoVO.setVipElectrovalence((tAccountingStrategyDetail.getServiceCharge().add(tAccountingStrategyDetail.getElectrovalence())).setScale(4, BigDecimal.ROUND_HALF_UP)); |
| | | } |
| | | if(Objects.nonNull(appUser)){ |
| | | // TVip vip = vipClient.getInfo1(appUser.getVipId()).getData(); |
| | | GetAppUserVipDetail getAppUserVipDetail = new GetAppUserVipDetail(); |
| | | getAppUserVipDetail.setAppUserId(userId); |
| | | getAppUserVipDetail.setVipId(appUser.getVipId()); |
| | | R<TAppUserVipDetail> appUserVipDetail = vipDetailClient.getAppUserVipDetail(getAppUserVipDetail); |
| | | TAppUserVipDetail data1 = appUserVipDetail.getData(); |
| | | if(Objects.nonNull(data1)){ |
| | | String vipJson = data1.getVipJson(); |
| | | TVip vip = JSON.parseObject(vipJson, TVip.class); |
| | | if(Objects.nonNull(vip) && vip.getType() == 2){ |
| | | siteInfoVO.setVipElectrovalence(vip.getDiscount().divide(new BigDecimal(10)).multiply(tAccountingStrategyDetail.getServiceCharge()).add(tAccountingStrategyDetail.getElectrovalence())); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | List<TVip> vips = vipClient.getVipList().getData(); |
| | |
| | | siteInfoVO.setCouponCount(num); |
| | | } |
| | | siteInfoVO.setChargingPileId(one.getId()); |
| | | siteInfoVO.setName(byId.getName()); |
| | | siteInfoVO.setName(site.getName()); |
| | | siteInfoVO.setNumber(one.getNumber().toString()); |
| | | siteInfoVO.setSpaceChargeExplain(byId.getSpaceChargeExplain()); |
| | | siteInfoVO.setSpaceChargeExplain(site.getSpaceChargeExplain()); |
| | | siteInfoVO.setSupportOrder(site.getSupportOrder()); |
| | | siteInfoVO.setReservationStartTime(site.getReservationStartTime()); |
| | | siteInfoVO.setReservationEndTime(site.getReservationEndTime()); |
| | | siteInfoVO.setVinFlag(one.getVinFlag()); |
| | | return R.ok(siteInfoVO); |
| | | } |
| | | |
| | | @RequiresPermissions(value = {"/systemUserManagement/update", "/site", "/platformRevenueAnalysis", "/chargingOperationAnalysis", |
| | | "/chargingUserAnalysis", "/operationMaintenanceAnalysis", "/chargingEquipmentMonitoring", "/activityExpense", "/chargeEvaluation/list", |
| | | "/parkingLot", "/workbench"}, logical = Logical.OR) |
| | | "/parkingLot", "/parkingRecord", "/workbench", "/invoiceManagement"}, logical = Logical.OR) |
| | | @GetMapping("/getSiteList") |
| | | @ApiOperation(value = "获取站点列表", tags = {"管理后台-站点管理"}) |
| | | public AjaxResult<PageInfo<GetSiteListDTO>> getSiteList(GetSiteList siteList){ |
| | |
| | | int isLogin = StringUtils.isEmpty(SecurityUtils.getToken(request)) ? 0 : 1; |
| | | return AjaxResult.success(siteService.pageList(query,isLogin)); |
| | | } |
| | | |
| | | |
| | | |
| | | @ApiOperation(value = "获取站点列表", tags = {"小程序-站点管理-地图导航站点"}) |
| | |
| | | int isLogin = StringUtils.isEmpty(SecurityUtils.getToken(request)) ? 0 : 1; |
| | | return AjaxResult.success(siteService.getMapSiteList(query,isLogin)); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "获取站点详细信息", tags = {"小程序-站点管理-站点详情"}) |
| | | @PostMapping("/getDetailById") |
| | | public AjaxResult<SiteDetailVO> getDetailById(@Validated @RequestBody SiteDetailQuery query){ |
| | |
| | | } |
| | | return AjaxResult.success(siteDetailVO); |
| | | } |
| | | |
| | | |
| | | |
| | | @ApiOperation(value = "获取站点下充电桩及充电枪列表", tags = {"小程序-站点管理-站点详情"}) |
| | | @GetMapping("/getChargingGunList") |
| | | public AjaxResult<List<TChargingPileVO>> getChargingGunList(@RequestParam(value = "siteId")@ApiParam(value = "站点id", required = true)Integer siteId, |
| | |
| | | return AjaxResult.success(chargingGunService.getChargingGunCount(siteId)); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "获取站点下充电枪数量统计", tags = {"小程序-站点管理-站点详情"}) |
| | | @GetMapping("/getChargingGunCount1") |
| | | public AjaxResult<Map<String,ChargingGunCountVO>> getChargingGunCount1(@RequestParam(value = "siteId")@ApiParam(value = "站点id", required = true)Integer siteId){ |
| | | return AjaxResult.success(chargingGunService.getChargingGunCount(siteId)); |
| | | } |
| | | |
| | | @RequiresPermissions(value = {"/site/add"}, logical = Logical.OR) |
| | | @GetMapping("/importTemplate") |
| | | @ApiOperation(value = "下载站点导入模板", tags = {"管理后台-站点管理"}) |
| | | public void importTemplate(HttpServletResponse response) { |
| | | ExcelUtil<SiteExcelDTO> util = new ExcelUtil<>(SiteExcelDTO.class); |
| | | util.importTemplateExcel(response, "站点导入模板", |
| | | "填写说明:所在区域填写区县行政区划代码;带*字段为必填;合作商、服务商、场地方和计费模板填写系统中的完整名称。") ; |
| | | } |
| | | |
| | | @RequiresPermissions(value = {"/site/add"}, logical = Logical.OR) |
| | | @PostMapping("/import") |
| | | @Log(title = "【站点管理】导入站点", businessType = BusinessType.IMPORT, operatorType = OperatorType.MANAGE) |
| | | @ApiOperation(value = "导入站点", tags = {"管理后台-站点管理"}) |
| | | public AjaxResult importSites(@RequestParam("file") MultipartFile file, |
| | | @RequestParam(value = "cover", defaultValue = "false") Boolean cover) throws Exception { |
| | | SiteImportResultDTO result = siteService.importSites(file, cover); |
| | | if (Boolean.TRUE.equals(result.getNeedConfirm())) { |
| | | return AjaxResult.error("发现重复站点编号,请确认是否覆盖", result); |
| | | } |
| | | if (result.getErrorCount() != null && result.getErrorCount() > 0) { |
| | | return AjaxResult.error("导入失败,请检查错误信息", result); |
| | | } |
| | | return AjaxResult.success("导入成功", result); |
| | | } |
| | | |
| | | @RequiresPermissions(value = {"/site/export", "/site"}, logical = Logical.OR) |
| | | @PutMapping("/export") |
| | | @Log(title = "【站点管理】导出站点", businessType = BusinessType.EXPORT, operatorType = OperatorType.MANAGE) |
| | | @ApiOperation(value = "导出站点", tags = {"管理后台-站点管理"}) |
| | | public void exportSites(@RequestBody GetSiteList query, HttpServletResponse response) { |
| | | List<Site> sites = siteService.listSitesForExport(query); |
| | | Set<Integer> partnerIds = sites.stream() |
| | | .flatMap(site -> Arrays.asList(site.getPartnerId(), site.getVenuePartnerId()).stream()) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toSet()); |
| | | Map<Integer, String> partnerNames = partnerIds.isEmpty() ? Collections.emptyMap() |
| | | : partnerService.listByIds(partnerIds).stream() |
| | | .collect(Collectors.toMap(Partner::getId, Partner::getName, (a, b) -> a)); |
| | | Set<Integer> strategyIds = sites.stream().map(Site::getAccountingStrategyId) |
| | | .filter(Objects::nonNull).collect(Collectors.toSet()); |
| | | Map<Integer, String> strategyNames = strategyIds.isEmpty() ? Collections.emptyMap() |
| | | : accountingStrategyService.listByIds(strategyIds).stream() |
| | | .collect(Collectors.toMap(TAccountingStrategy::getId, TAccountingStrategy::getName, (a, b) -> a)); |
| | | List<SiteExcelDTO> rows = sites.stream().map(site -> SiteExcelDTO.from(site, |
| | | partnerNames.get(site.getPartnerId()), partnerNames.get(site.getVenuePartnerId()), |
| | | strategyNames.get(site.getAccountingStrategyId()))).collect(Collectors.toList()); |
| | | new ExcelUtil<>(SiteExcelDTO.class).exportExcel(response, rows, "站点数据"); |
| | | } |
| | | |
| | | @RequiresPermissions(value = {"/site/add"}, logical = Logical.OR) |
| | |
| | | |
| | | |
| | | |
| | | @RequiresPermissions(value = {"/site/update"}, logical = Logical.OR) |
| | | @ResponseBody |
| | | @PostMapping("/getReservationSetting/{id}") |
| | | @ApiOperation(value = "获取站点预约设置", tags = {"管理后台-站点管理"}) |
| | | public AjaxResult<Site> getReservationSetting(@PathVariable Integer id){ |
| | | Site site = siteService.lambdaQuery() |
| | | .select(Site::getId, Site::getName, Site::getSupportOrder, Site::getReservationStartTime, Site::getReservationEndTime, Site::getReservationAheadMinute) |
| | | .eq(Site::getId, id) |
| | | .eq(Site::getDelFlag, 0) |
| | | .one(); |
| | | return AjaxResult.success(site); |
| | | } |
| | | |
| | | @RequiresPermissions(value = {"/site/update"}, logical = Logical.OR) |
| | | @ResponseBody |
| | | @PostMapping("/saveReservationSetting") |
| | | @ApiOperation(value = "保存站点预约设置", tags = {"管理后台-站点管理"}) |
| | | public AjaxResult saveReservationSetting(@RequestBody Site site){ |
| | | if (site == null || site.getId() == null) { |
| | | return AjaxResult.error("站点id不能为空"); |
| | | } |
| | | boolean success = siteService.lambdaUpdate() |
| | | .eq(Site::getId, site.getId()) |
| | | .eq(Site::getDelFlag, 0) |
| | | .set(Site::getSupportOrder, site.getSupportOrder()) |
| | | .set(Site::getReservationStartTime, site.getReservationStartTime()) |
| | | .set(Site::getReservationEndTime, site.getReservationEndTime()) |
| | | .set(Site::getReservationAheadMinute, site.getReservationAheadMinute()) |
| | | .update(); |
| | | return success ? AjaxResult.success() : AjaxResult.error("保存预约设置失败"); |
| | | } |
| | | @RequiresPermissions(value = {"/site/update"}, logical = Logical.OR) |
| | | @ResponseBody |
| | | @PostMapping("/editSite") |
| | | @ApiOperation(value = "编辑站点", tags = {"管理后台-站点管理"}) |
| | |
| | | siteService.setAccountingStrategy(id, accountingStrategyId); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @RequiresPermissions(value = {"/site/accounting_strategy"}, logical = Logical.OR) |
| | | @PostMapping("/batchSetAccountingStrategy") |
| | | @ApiOperation(value = "批量设置站点计费策略", tags = {"管理后台-站点管理"}) |
| | | @Log(title = "【站点管理】批量设置站点计费策略", businessType = BusinessType.UPDATE) |
| | | public AjaxResult batchSetAccountingStrategy(@RequestBody BatchSetSiteAccountingStrategyDTO request){ |
| | | if (request == null || CollectionUtils.isEmpty(request.getIds())) { |
| | | return AjaxResult.error("请选择要设置计费策略的站点"); |
| | | } |
| | | if (request.getAccountingStrategyId() == null) { |
| | | return AjaxResult.error("请选择计费模板"); |
| | | } |
| | | siteService.batchSetAccountingStrategy(request.getIds(), request.getAccountingStrategyId()); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | |
| | | @RequiresPermissions(value = {"/roleManagement/add", "/roleManagement/info", "/roleManagement/update", "/systemNotification", "/chargingPeriodStatistics", |
| | | "/parkingPaymentOrder", "/generateStatement", "/chargingPile/add", "/chargingPile/select", "/chargingPile/update"}, logical = Logical.OR) |
| | | "/parkingPaymentOrder", "/generateStatement", "/chargingPile/add", "/chargingPile/select", "/chargingPile/update", |
| | | "/appUserWhitelist/add", "/appUserWhitelist/update", "/appUserWhitelist/import"}, logical = Logical.OR) |
| | | @ResponseBody |
| | | @GetMapping("/getAllSiteList") |
| | | @ApiOperation(value = "获取所有站点数据", tags = {"管理后台-充电桩信息", "管理后台-系统用户管理", "管理后台-角色管理", "管理后台-系统通知", "管理后台-充电评价"}) |
| | |
| | | @ResponseBody |
| | | @PostMapping("/getSiteByIds") |
| | | public R<List<Site>> getSiteByIds(@RequestBody List<Integer> ids){ |
| | | if (CollectionUtils.isEmpty(ids)) { |
| | | return R.ok(Collections.emptyList()); |
| | | } |
| | | List<Site> sites = siteService.list(new LambdaQueryWrapper<Site>().in(Site::getId, ids).eq(Site::getDelFlag, 0)); |
| | | return R.ok(sites); |
| | | } |
| | | |
| | | @GetMapping("/getSitesByIds") |
| | | @ApiOperation(value = "小程序批量获取站点基础信息", tags = {"小程序-收藏"}) |
| | | public R<List<Site>> getSitesByIds(@RequestParam String ids) { |
| | | List<Integer> siteIds = Arrays.stream(ids.split(",")) |
| | | .filter(StringUtils::isNotEmpty) |
| | | .map(Integer::valueOf) |
| | | .collect(Collectors.toList()); |
| | | if (siteIds.isEmpty()) { |
| | | return R.ok(Collections.emptyList()); |
| | | } |
| | | return R.ok(siteService.list(new LambdaQueryWrapper<Site>() |
| | | .in(Site::getId, siteIds) |
| | | .eq(Site::getDelFlag, 0))); |
| | | } |
| | | |
| | | @PostMapping("/favoriteSitePrices") |
| | | @ApiOperation(value = "批量获取收藏站点当前价格", tags = {"内部接口-收藏"}) |
| | | public R<List<FavoriteSitePriceVO>> favoriteSitePrices(@RequestBody List<Integer> ids) { |
| | | if (CollectionUtils.isEmpty(ids)) { |
| | | return R.ok(Collections.emptyList()); |
| | | } |
| | | List<Site> sites = siteService.list(new LambdaQueryWrapper<Site>() |
| | | .in(Site::getId, ids) |
| | | .eq(Site::getDelFlag, 0)); |
| | | List<FavoriteSitePriceVO> result = sites.stream().map(site -> { |
| | | FavoriteSitePriceVO vo = new FavoriteSitePriceVO(); |
| | | vo.setSiteId(site.getId()); |
| | | vo.setSiteName(site.getName()); |
| | | vo.setStatus(site.getStatus()); |
| | | vo.setCurrentPrice(getCurrentSitePrice(site)); |
| | | return vo; |
| | | }).collect(Collectors.toList()); |
| | | return R.ok(result); |
| | | } |
| | | |
| | | private BigDecimal getCurrentSitePrice(Site site) { |
| | | if (site.getAccountingStrategyId() == null) { |
| | | return null; |
| | | } |
| | | LocalTime now = LocalTime.now(); |
| | | List<TAccountingStrategyDetail> details = accountingStrategyDetailService.lambdaQuery() |
| | | .eq(TAccountingStrategyDetail::getAccountingStrategyId, site.getAccountingStrategyId()) |
| | | .list(); |
| | | for (TAccountingStrategyDetail detail : details) { |
| | | LocalTime start = parsePriceTime(detail.getStartTime(), false); |
| | | LocalTime end = parsePriceTime(detail.getEndTime(), true); |
| | | if (start != null && end != null && !now.isBefore(start) && !now.isAfter(end)) { |
| | | return detail.getElectrovalence().add(detail.getServiceCharge()) |
| | | .setScale(4, BigDecimal.ROUND_HALF_UP); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private LocalTime parsePriceTime(String value, boolean endTime) { |
| | | if (StringUtils.isEmpty(value)) { |
| | | return null; |
| | | } |
| | | if (endTime && "00:00".equals(value)) { |
| | | return LocalTime.of(23, 59, 59); |
| | | } |
| | | return LocalTime.parse(value.length() == 5 ? value + ":00" : value); |
| | | } |
| | | |
| | | |
| | |
| | | * @return |
| | | */ |
| | | @PostMapping("/getSiteListPaging") |
| | | public PageInfo<Site> getSiteListPaging(@RequestParam("PageNo") Integer PageNo, @RequestParam("PageSize") Integer PageSize){ |
| | | public PageInfo<Site> getSiteListPaging(@RequestParam("PageNo") Integer PageNo, @RequestParam("PageSize") Integer PageSize, |
| | | @RequestParam("ids") List<String> ids, @RequestParam("isOpenSynchronization") Integer isOpenSynchronization){ |
| | | PageInfo<Site> pageInfo = new PageInfo<>(PageNo, PageSize); |
| | | PageInfo<Site> page = siteService.lambdaQuery().eq(Site::getStatus, 1).page(pageInfo); |
| | | PageInfo<Site> page = siteService.lambdaQuery().eq(Site::getStatus, 1) |
| | | .in(ids.size() > 0, Site::getId, ids) |
| | | .eq(-1 != isOpenSynchronization, Site::getIsOpenSynchronization, isOpenSynchronization) |
| | | .ne(Site::getSiteType, 2).page(pageInfo); |
| | | return page; |
| | | } |
| | | /** |
| | | * 分页查询站电数据 |
| | | * @param PageNo |
| | | * @param PageSize |
| | | * @return |
| | | */ |
| | | @PostMapping("/getSiteListPagingJianGuan") |
| | | public PageInfo<Site> getSiteListPagingJianGuan(@RequestParam("PageNo") Integer PageNo, @RequestParam("PageSize") Integer PageSize, |
| | | @RequestParam("ids") List<String> ids){ |
| | | PageInfo<Site> pageInfo = new PageInfo<>(PageNo, PageSize); |
| | | PageInfo<Site> page = siteService.lambdaQuery().eq(Site::getStatus, 1).in(ids.size() > 0, Site::getId, ids).page(pageInfo); |
| | | return page; |
| | | } |
| | | } |