Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/mx_charging_pile
| | |
| | | generator |
| | | .idea |
| | | |
| | | target |
| | | target |
| | | |
| | | *.yaml |
| | | *.yml |
New file |
| | |
| | | package com.ruoyi.chargingPile.api.dto; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2024/8/9 10:30 |
| | | */ |
| | | @Data |
| | | @ApiModel |
| | | public class GetPermissionConfigurationDTO { |
| | | @ApiModelProperty(value = "备注") |
| | | private String permissionRemarks; |
| | | @ApiModelProperty(value = "权限菜单") |
| | | private Map<String, Object> menu; |
| | | } |
| | |
| | | private Integer accountingStrategyId; |
| | | @ApiModelProperty("计费策略类型(1=平台添加,2=自定义策略)") |
| | | private Integer accountingStrategyType; |
| | | @ApiModelProperty(value = "计费策略权限") |
| | | private boolean authAccountingStrategy = true; |
| | | @ApiModelProperty(value = "合作商权限") |
| | | private boolean authPartner = true; |
| | | @ApiModelProperty(value = "编辑权限") |
| | | private boolean authUpdate = true; |
| | | @ApiModelProperty(value = "删除权限") |
| | | private boolean authDelete = true; |
| | | } |
| | |
| | | private String equipmentType; |
| | | @ApiModelProperty(value = "额定功率") |
| | | private BigDecimal ratedPower; |
| | | @ApiModelProperty(value = "查看权限") |
| | | private boolean authQueryInfo = true; |
| | | @ApiModelProperty(value = "编辑权限") |
| | | private boolean authUpdate = true; |
| | | @ApiModelProperty(value = "删除权限") |
| | | private boolean authDelete = true; |
| | | @ApiModelProperty(value = "新增接口权限") |
| | | private boolean authAddChargingGun = true; |
| | | |
| | | } |
| | |
| | | @TableField("password") |
| | | @ApiModelProperty(value = "登录密码", required = true) |
| | | private String password; |
| | | /** |
| | | * 权限备注 |
| | | */ |
| | | @TableField("permission_remarks") |
| | | private String permissionRemarks; |
| | | } |
| | |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | |
| | | private Long appUserId; |
| | | |
| | | @ApiModelProperty(value = "用电地址") |
| | | @NotBlank(message = "用电地址不能为空") |
| | | @TableField("address") |
| | | private String address; |
| | | |
| | |
| | | @TableField("is_cache") |
| | | private Integer isCache; |
| | | |
| | | @ApiModelProperty(value = "菜单类型(M目录 C菜单 F按钮)") |
| | | @ApiModelProperty(value = "菜单类型(M目录 C菜单 F按钮 D数据)") |
| | | @TableField("menu_type") |
| | | private String menuType; |
| | | |
New file |
| | |
| | | package com.ruoyi.chargingPile.api.query; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2024/8/9 11:13 |
| | | */ |
| | | @Data |
| | | @ApiModel |
| | | public class SetPermissionConfiguration { |
| | | @ApiModelProperty(value = "备注") |
| | | private String permissionRemarks; |
| | | @ApiModelProperty(value = "权限菜单id数组", required = true) |
| | | private List<Integer> menuId; |
| | | @ApiModelProperty(value = "站点id", required = true) |
| | | private Integer siteId; |
| | | @ApiModelProperty(value = "合作商id", required = true) |
| | | private Integer partnerId; |
| | | } |
New file |
| | |
| | | package com.ruoyi.chargingPile.api.query; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | import java.io.Serializable; |
| | | |
| | | @Data |
| | | @ApiModel(value = "SiteDetailQuery对象",description = "站点详情查询条件") |
| | | public class SiteDetailQuery implements Serializable { |
| | | |
| | | @ApiModelProperty(value = "站点id") |
| | | @NotNull(message = "站点id不能为空") |
| | | private Integer siteId; |
| | | |
| | | @ApiModelProperty(value = "经度") |
| | | @NotBlank(message = "地址经度不能为空") |
| | | private String lon; |
| | | |
| | | @ApiModelProperty(value = "纬度") |
| | | @NotBlank(message = "地址纬度不能为空") |
| | | private String lat; |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.chargingPile.api.vo; |
| | | |
| | | import com.ruoyi.chargingPile.api.model.Site; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | @ApiModel(value = "ChargingGunCountVO对象",description = "充电枪数量VO") |
| | | public class ChargingGunCountVO extends Site { |
| | | |
| | | @ApiModelProperty(value = "充电枪在线数量") |
| | | private Integer freeCount; |
| | | @ApiModelProperty(value = "充电枪总数数量") |
| | | private Integer totalCount; |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.chargingPile.api.vo; |
| | | |
| | | import com.ruoyi.chargingPile.api.model.Site; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | @ApiModel(value = "SiteDetailVO对象",description = "站点详情VO") |
| | | public class SiteDetailVO extends Site { |
| | | |
| | | @ApiModelProperty(value = "绑定车牌提示文案") |
| | | private String bindCarTips; |
| | | @ApiModelProperty(value = "距离") |
| | | private double distance; |
| | | |
| | | } |
| | |
| | | |
| | | @ApiModelProperty(value = "策略名称") |
| | | private String strategyName; |
| | | |
| | | @ApiModelProperty(value = "编辑权限") |
| | | private boolean authUpdate = true; |
| | | |
| | | @ApiModelProperty(value = "删除权限") |
| | | private boolean authDelete = true; |
| | | |
| | | @ApiModelProperty(value = "查看费率权限") |
| | | private boolean authViewRates = true; |
| | | |
| | | @ApiModelProperty(value = "编辑权限") |
| | | private boolean authDownloadQRCode = true; |
| | | |
| | | @ApiModelProperty(value = "编辑权限") |
| | | private boolean authQueryInfo = true; |
| | | |
| | | @ApiModelProperty(value = "编辑权限") |
| | | private boolean authEndCharge = true; |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.chargingPile.api.vo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.ruoyi.chargingPile.api.model.TChargingGun; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | @ApiModel(value = "TChargingPileVO对象",description = "充电桩信息") |
| | | public class TChargingPileVO implements Serializable { |
| | | @ApiModelProperty(value = "充电桩id") |
| | | private Integer id; |
| | | |
| | | @ApiModelProperty(value = "设备编号") |
| | | private String code; |
| | | |
| | | @ApiModelProperty(value = "充电设备名称") |
| | | private String name; |
| | | |
| | | @ApiModelProperty(value = "桩号") |
| | | private Integer number; |
| | | |
| | | @ApiModelProperty(value = "充电枪信息列表") |
| | | private List<TChargingGun> chargingGunList; |
| | | |
| | | } |
| | |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | import java.io.Serializable; |
| | | import java.time.LocalDateTime; |
| | | |
| | |
| | | private Long appUserId; |
| | | |
| | | @ApiModelProperty(value = "公司名称") |
| | | @NotBlank(message = "公司名称不能为空") |
| | | @TableField("company_name") |
| | | private String companyName; |
| | | |
| | | @ApiModelProperty(value = "汽车数量") |
| | | @NotNull(message = "汽车数量不能为空") |
| | | @TableField("vehicles_number") |
| | | private Integer vehiclesNumber; |
| | | |
| | | @ApiModelProperty(value = "联系人姓名") |
| | | @NotBlank(message = "联系人姓名不能为空") |
| | | @TableField("contact_name") |
| | | private String contactName; |
| | | |
| | | @ApiModelProperty(value = "联系人电话") |
| | | @NotBlank(message = "联系人电话不能为空") |
| | | @TableField("phone") |
| | | private String phone; |
| | | |
| | |
| | | public R unitDelete(Integer id) { |
| | | return R.fail("删除单位失败:" + throwable.getMessage()); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public R<TCompany> unitDetail(Integer id) { |
| | | return R.fail("查询单位失败:" + throwable.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public R<Page<TUserTag>> queryTagPage(TagListQueryDto unitListQueryDto) { |
| | | return R.fail("查询标签:" + throwable.getMessage()); |
New file |
| | |
| | | package com.ruoyi.other.api.factory; |
| | | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.other.api.feignClient.RoleSiteClient; |
| | | import com.ruoyi.other.api.feignClient.UserSiteClient; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.cloud.openfeign.FallbackFactory; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 商品服务降级处理 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Component |
| | | public class RoleSiteFallbackFactory implements FallbackFactory<RoleSiteClient> { |
| | | private static final Logger log = LoggerFactory.getLogger(RoleSiteFallbackFactory.class); |
| | | |
| | | @Override |
| | | public RoleSiteClient create(Throwable throwable) { |
| | | log.error("调用失败:{}", throwable.getMessage()); |
| | | return new RoleSiteClient() { |
| | | |
| | | @Override |
| | | public R<List<Integer>> getSiteIds(Long roleId) { |
| | | return R.fail("获取角色站点失败:" + throwable.getMessage()); |
| | | } |
| | | }; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.other.api.factory; |
| | | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.other.api.feignClient.UserSiteClient; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.cloud.openfeign.FallbackFactory; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 商品服务降级处理 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Component |
| | | public class UserSiteFallbackFactory implements FallbackFactory<UserSiteClient> { |
| | | private static final Logger log = LoggerFactory.getLogger(UserSiteFallbackFactory.class); |
| | | |
| | | @Override |
| | | public UserSiteClient create(Throwable throwable) { |
| | | log.error("调用失败:{}", throwable.getMessage()); |
| | | return new UserSiteClient() { |
| | | |
| | | @Override |
| | | public R<List<Integer>> getSiteIds(Long userId) { |
| | | return R.fail("获取用户站点失败:" + throwable.getMessage()); |
| | | } |
| | | }; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.other.api.feignClient; |
| | | |
| | | import com.ruoyi.common.core.constant.ServiceNameConstants; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.other.api.factory.RoleSiteFallbackFactory; |
| | | import com.ruoyi.other.api.factory.UserSiteFallbackFactory; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2024/8/9 18:14 |
| | | */ |
| | | @FeignClient(contextId = "RoleSiteClient", value = ServiceNameConstants.CONTRACT_SERVICE, fallbackFactory = RoleSiteFallbackFactory.class) |
| | | public interface RoleSiteClient { |
| | | |
| | | |
| | | /** |
| | | * 根据角色id获取可访问的站点数据 |
| | | * @param roleId |
| | | * @return |
| | | */ |
| | | @GetMapping("/t-user-site/getSiteIds") |
| | | R<List<Integer>> getSiteIds(@RequestParam("roleId") Long roleId); |
| | | } |
New file |
| | |
| | | package com.ruoyi.other.api.feignClient; |
| | | |
| | | import com.ruoyi.common.core.constant.ServiceNameConstants; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.other.api.factory.UserSiteFallbackFactory; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2024/8/9 18:14 |
| | | */ |
| | | @FeignClient(contextId = "UserSiteClient", value = ServiceNameConstants.CONTRACT_SERVICE, fallbackFactory = UserSiteFallbackFactory.class) |
| | | public interface UserSiteClient { |
| | | |
| | | |
| | | /** |
| | | * 根据用户id获取可访问的站点数据 |
| | | * @param userId |
| | | * @return |
| | | */ |
| | | @GetMapping("/t-user-site/getSiteIds") |
| | | R<List<Integer>> getSiteIds(@RequestParam("userId") Long userId); |
| | | } |
| | |
| | | com.ruoyi.other.api.factory.GoodsFallbackFactory |
| | | com.ruoyi.other.api.factory.OtherFallbackFactory |
| | | com.ruoyi.other.api.factory.UserSiteFallbackFactory |
| | | com.ruoyi.other.api.factory.RoleSiteFallbackFactory |
| | |
| | | |
| | | /** 用户头像 */ |
| | | private String avatar; |
| | | /** |
| | | * 登录账号 |
| | | */ |
| | | @TableField("account") |
| | | private String account; |
| | | |
| | | /** 密码 */ |
| | | @NotBlank(message = "密码不能为空") |
| | |
| | | public void setAvatar(String avatar) |
| | | { |
| | | this.avatar = avatar; |
| | | } |
| | | |
| | | public String getAccount() { |
| | | return account; |
| | | } |
| | | |
| | | public void setAccount(String account) { |
| | | this.account = account; |
| | | } |
| | | |
| | | public String getPassword() |
| | |
| | | } |
| | | |
| | | @Override |
| | | public R<SysUser> queryUserByAccount(String account) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public R<SysUser> queryUserByUserName(String userName) { |
| | | return R.fail("通过账号查询用户失败:" + cause.getMessage()); |
| | | } |
| | |
| | | |
| | | @Override |
| | | public R resetPassword(SysUser user) { |
| | | return null; |
| | | return R.fail("重置用户密码失败:" + cause.getMessage()); |
| | | } |
| | | }; |
| | | } |
| | |
| | | */ |
| | | @PostMapping("/user/queryUserByPhone") |
| | | R<SysUser> queryUserByPhone(@RequestBody String phone); |
| | | |
| | | |
| | | /** |
| | | * 根据账号获取用户数据 |
| | | * @param account |
| | | * @return |
| | | */ |
| | | @PostMapping("/user/queryUserByAccount") |
| | | R<SysUser> queryUserByAccount(@RequestBody String account); |
| | | |
| | | /** |
| | | * 通过账号查询用户 |
| | |
| | | <version>2.8.0</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.gavaghan</groupId> |
| | | <artifactId>geodesy</artifactId> |
| | | <version>1.1.3</version> |
| | | </dependency> |
| | | |
| | | </dependencies> |
| | | |
New file |
| | |
| | | package com.ruoyi.common.core.enums.status; |
| | | |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * @Description |
| | | * @Author xiaochen |
| | | * @Date 2023/6/8 16:42 |
| | | */ |
| | | public enum ChargingGunModeEnum { |
| | | |
| | | |
| | | SUPER_SUFFICIENT(1, "超级快充"), |
| | | FAST_SUFFICIENT(2, "快充"), |
| | | SLOW_SUFFICIENT(3, "慢充"); |
| | | |
| | | @Getter |
| | | private String desc; |
| | | |
| | | |
| | | @Getter |
| | | private int code; |
| | | |
| | | |
| | | ChargingGunModeEnum(int code, String desc) { |
| | | this.code = code; |
| | | this.desc = desc; |
| | | } |
| | | |
| | | /** |
| | | * 通过code获取枚举 |
| | | * |
| | | * @param code |
| | | * @return |
| | | */ |
| | | public static ChargingGunModeEnum fromCode(Integer code) { |
| | | ChargingGunModeEnum[] resultTypes = ChargingGunModeEnum.values(); |
| | | for (ChargingGunModeEnum resultType : resultTypes) { |
| | | if (code.equals(resultType.getCode())) { |
| | | return resultType; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.core.enums.status; |
| | | |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * @Description |
| | | * @Author xiaochen |
| | | * @Date 2023/6/8 16:42 |
| | | */ |
| | | public enum ChargingGunStatusEnum { |
| | | |
| | | |
| | | OFFLINE(1, "离线"), |
| | | IDLE(2, "空闲"), |
| | | OCCUPATION_UNCHARGED(3, "占用(未充电)"), |
| | | OCCUPATION_CHARGING(4, "占用(充电中)"), |
| | | OCCUPATION_FULL(5, "占用(已充满)"), |
| | | OCCUPATION_LOCK(6, "占用(预约锁定)"), |
| | | FAULT(7, "故障"); |
| | | |
| | | @Getter |
| | | private String desc; |
| | | |
| | | |
| | | @Getter |
| | | private int code; |
| | | |
| | | |
| | | ChargingGunStatusEnum(int code, String desc) { |
| | | this.code = code; |
| | | this.desc = desc; |
| | | } |
| | | |
| | | /** |
| | | * 通过code获取枚举 |
| | | * |
| | | * @param code |
| | | * @return |
| | | */ |
| | | public static ChargingGunStatusEnum fromCode(Integer code) { |
| | | ChargingGunStatusEnum[] resultTypes = ChargingGunStatusEnum.values(); |
| | | for (ChargingGunStatusEnum resultType : resultTypes) { |
| | | if (code.equals(resultType.getCode())) { |
| | | return resultType; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.core.utils; |
| | | |
| | | import org.gavaghan.geodesy.Ellipsoid; |
| | | import org.gavaghan.geodesy.GeodeticCalculator; |
| | | import org.gavaghan.geodesy.GeodeticCurve; |
| | | import org.gavaghan.geodesy.GlobalCoordinates; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 计算两个金纬度坐标之间的直线距离 |
| | | */ |
| | | public class GeodesyUtil { |
| | | |
| | | |
| | | /** |
| | | * 获取直线距离 |
| | | * @param fromLonLat |
| | | * @param toLonLat |
| | | * @return |
| | | */ |
| | | public static Map<String, Double> getDistance(String fromLonLat, String toLonLat){ |
| | | Map<String, Double> map = null; |
| | | if(StringUtils.isNotEmpty(fromLonLat) && StringUtils.isNotEmpty(toLonLat)){ |
| | | map = new HashMap<>(); |
| | | String[] from = fromLonLat.split(","); |
| | | String[] to = toLonLat.split(","); |
| | | GlobalCoordinates source = new GlobalCoordinates(Double.valueOf(from[1]), Double.valueOf(from[0])); |
| | | GlobalCoordinates target = new GlobalCoordinates(Double.valueOf(to[1]), Double.valueOf(to[0])); |
| | | double Sphere = getDistanceMeter(source, target, Ellipsoid.Sphere); |
| | | double WGS84 = getDistanceMeter(source, target, Ellipsoid.WGS84); |
| | | double GRS80 = getDistanceMeter(source, target, Ellipsoid.GRS80); |
| | | double GRS67 = getDistanceMeter(source, target, Ellipsoid.GRS67); |
| | | double ANS = getDistanceMeter(source, target, Ellipsoid.ANS); |
| | | double WGS72 = getDistanceMeter(source, target, Ellipsoid.WGS72); |
| | | double Clarke1858 = getDistanceMeter(source, target, Ellipsoid.Clarke1858); |
| | | double Clarke1880 = getDistanceMeter(source, target, Ellipsoid.Clarke1880); |
| | | // System.out.println("Sphere坐标系计算结果:"+Sphere + "米"); |
| | | // System.out.println("WGS84坐标系计算结果:"+WGS84 + "米"); |
| | | // System.out.println("GRS80坐标系计算结果:"+GRS80 + "米"); |
| | | // System.out.println("GRS67坐标系计算结果:"+GRS67 + "米"); |
| | | // System.out.println("ANS坐标系计算结果:"+ANS + "米"); |
| | | // System.out.println("WGS72坐标系计算结果:"+WGS72 + "米"); |
| | | // System.out.println("Clarke1858坐标系计算结果:"+Clarke1858 + "米"); |
| | | // System.out.println("Clarke1880坐标系计算结果:"+Clarke1880 + "米"); |
| | | map.put("Sphere", Sphere); |
| | | map.put("WGS84", WGS84); |
| | | map.put("GRS80", GRS80); |
| | | map.put("GRS67", GRS67); |
| | | map.put("ANS", ANS); |
| | | map.put("WGS72", WGS72); |
| | | map.put("Clarke1858", Clarke1858); |
| | | map.put("Clarke1880", Clarke1880); |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | |
| | | private static double getDistanceMeter(GlobalCoordinates gpsFrom, GlobalCoordinates gpsTo, Ellipsoid ellipsoid){ |
| | | //创建GeodeticCalculator,调用计算方法,传入坐标系、经纬度用于计算距离 |
| | | GeodeticCurve geoCurve = new GeodeticCalculator().calculateGeodeticCurve(ellipsoid, gpsFrom, gpsTo); |
| | | return geoCurve.getEllipsoidalDistance(); |
| | | } |
| | | |
| | | |
| | | |
| | | public static void main(String[] ages){ |
| | | GeodesyUtil geodesyUtil = new GeodesyUtil(); |
| | | Map<String, Double> distance = geodesyUtil.getDistance("115.481028,39.989643", "114.465302,40.004717"); |
| | | System.err.println(distance); |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.gateway.filter; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import org.apache.commons.codec.binary.Base64; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import org.springframework.cloud.gateway.filter.GatewayFilterChain; |
| | | import org.springframework.cloud.gateway.filter.GlobalFilter; |
| | | import org.springframework.core.Ordered; |
| | | import org.springframework.core.io.buffer.DataBuffer; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.server.reactive.ServerHttpRequest; |
| | | import org.springframework.http.server.reactive.ServerHttpRequestDecorator; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.server.ServerWebExchange; |
| | | import com.ruoyi.common.core.constant.CacheConstants; |
| | |
| | | import com.ruoyi.common.redis.service.RedisService; |
| | | import com.ruoyi.gateway.config.properties.IgnoreWhiteProperties; |
| | | import io.jsonwebtoken.Claims; |
| | | import reactor.core.publisher.Flux; |
| | | import reactor.core.publisher.Mono; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | | import java.util.concurrent.atomic.AtomicReference; |
| | | |
| | | /** |
| | | * 网关鉴权 |
| | |
| | | |
| | | @Autowired |
| | | private RedisService redisService; |
| | | |
| | | @Value("${security.sign}") |
| | | private boolean parameter_signature; |
| | | |
| | | |
| | | @Override |
| | |
| | | if (StringUtils.isEmpty(userid) || StringUtils.isEmpty(username)) { |
| | | return unauthorizedResponse(exchange, "令牌验证失败"); |
| | | } |
| | | if(parameter_signature){ |
| | | String sign = request.getHeaders().getFirst(TokenConstants.SING); |
| | | String nonce_str = request.getHeaders().getFirst(TokenConstants.NONCE_STR); |
| | | if(StringUtils.isEmpty(sign) || StringUtils.isEmpty(nonce_str)){ |
| | | log.error("[鉴权签名异常处理]请求路径:{}", exchange.getRequest().getPath()); |
| | | return ServletUtils.webFluxResponseWriter(exchange.getResponse(), "签名校验失败", HttpStatus.BAD_REQUEST); |
| | | } |
| | | } |
| | | |
| | | |
| | | // 设置用户信息到请求 |
| | | addHeader(mutate, SecurityConstants.USER_KEY, userkey); |
| | | addHeader(mutate, SecurityConstants.DETAILS_USER_ID, userid); |
| | |
| | | } |
| | | return token; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public int getOrder() |
| | | { |
| | | return -200; |
| | | return -300; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.gateway.filter; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.ruoyi.common.core.constant.HttpStatus; |
| | | import com.ruoyi.common.core.constant.TokenConstants; |
| | | import com.ruoyi.common.core.utils.ServletUtils; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.utils.html.EscapeUtil; |
| | | import com.ruoyi.gateway.config.properties.XssProperties; |
| | | import io.netty.buffer.ByteBufAllocator; |
| | | import org.apache.commons.codec.binary.Base64; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
| | | import org.springframework.cloud.gateway.filter.GatewayFilterChain; |
| | | import org.springframework.cloud.gateway.filter.GlobalFilter; |
| | | import org.springframework.core.Ordered; |
| | | import org.springframework.core.io.buffer.*; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.HttpMethod; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.http.server.reactive.ServerHttpRequest; |
| | | import org.springframework.http.server.reactive.ServerHttpRequestDecorator; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.server.ServerWebExchange; |
| | | import reactor.core.publisher.Flux; |
| | | import reactor.core.publisher.Mono; |
| | | |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | | import java.util.concurrent.atomic.AtomicReference; |
| | | |
| | | /** |
| | | * 跨站脚本过滤器 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Component |
| | | public class RequestParamGlobalFilter implements GlobalFilter, Ordered { |
| | | |
| | | |
| | | |
| | | @Override |
| | | public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) { |
| | | ServerHttpRequestDecorator httpRequestDecorator = requestDecorator(exchange); |
| | | return chain.filter(exchange.mutate().request(httpRequestDecorator).build()); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | private ServerHttpRequestDecorator requestDecorator(ServerWebExchange exchange) { |
| | | ServerHttpRequestDecorator serverHttpRequestDecorator = new ServerHttpRequestDecorator(exchange.getRequest()) { |
| | | @Override |
| | | public Flux<DataBuffer> getBody() { |
| | | Flux<DataBuffer> body = super.getBody(); |
| | | return body.buffer().map(dataBuffers -> { |
| | | DataBufferFactory dataBufferFactory = new DefaultDataBufferFactory(); |
| | | DataBuffer join = dataBufferFactory.join(dataBuffers); |
| | | byte[] content = new byte[join.readableByteCount()]; |
| | | join.read(content); |
| | | DataBufferUtils.release(join); |
| | | String bodyStr = new String(content, StandardCharsets.UTF_8); |
| | | // 转成字节 |
| | | byte[] bytes = bodyStr.getBytes(); |
| | | NettyDataBufferFactory nettyDataBufferFactory = new NettyDataBufferFactory(ByteBufAllocator.DEFAULT); |
| | | DataBuffer buffer = nettyDataBufferFactory.allocateBuffer(bytes.length); |
| | | buffer.write(bytes); |
| | | return buffer; |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public HttpHeaders getHeaders() { |
| | | HttpHeaders httpHeaders = new HttpHeaders(); |
| | | httpHeaders.putAll(super.getHeaders()); |
| | | // 由于修改了请求体的body,导致content-length长度不确定,因此需要删除原先的content-length |
| | | httpHeaders.remove(HttpHeaders.CONTENT_LENGTH); |
| | | httpHeaders.set(HttpHeaders.TRANSFER_ENCODING, "chunked"); |
| | | return httpHeaders; |
| | | } |
| | | |
| | | }; |
| | | return serverHttpRequestDecorator; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public int getOrder() |
| | | { |
| | | return HIGHEST_PRECEDENCE; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.gateway.filter; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.ruoyi.common.core.constant.CacheConstants; |
| | | import com.ruoyi.common.core.constant.HttpStatus; |
| | | import com.ruoyi.common.core.constant.SecurityConstants; |
| | | import com.ruoyi.common.core.constant.TokenConstants; |
| | | import com.ruoyi.common.core.utils.JwtUtils; |
| | | import com.ruoyi.common.core.utils.ServletUtils; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.redis.service.RedisService; |
| | | import com.ruoyi.gateway.config.properties.IgnoreWhiteProperties; |
| | | import io.jsonwebtoken.Claims; |
| | | import org.apache.commons.codec.binary.Base64; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.cloud.gateway.filter.GatewayFilterChain; |
| | | import org.springframework.cloud.gateway.filter.GlobalFilter; |
| | | import org.springframework.core.Ordered; |
| | | import org.springframework.core.io.buffer.DataBuffer; |
| | | import org.springframework.core.io.buffer.DataBufferUtils; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.HttpMethod; |
| | | import org.springframework.http.server.reactive.ServerHttpRequest; |
| | | import org.springframework.http.server.reactive.ServerHttpRequestDecorator; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.server.ServerWebExchange; |
| | | import reactor.core.publisher.Flux; |
| | | import reactor.core.publisher.Mono; |
| | | |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | | import java.util.concurrent.atomic.AtomicReference; |
| | | |
| | | /** |
| | | * 网关鉴权 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Component |
| | | public class SignFilter implements GlobalFilter, Ordered { |
| | | private static final Logger log = LoggerFactory.getLogger(SignFilter.class); |
| | | |
| | | // 排除过滤的 uri 地址,nacos自行添加 |
| | | @Autowired |
| | | private IgnoreWhiteProperties ignoreWhite; |
| | | |
| | | @Autowired |
| | | private RedisService redisService; |
| | | |
| | | @Value("${security.sign}") |
| | | private boolean parameter_signature; |
| | | |
| | | |
| | | @Override |
| | | public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) { |
| | | ServerHttpRequest request = exchange.getRequest(); |
| | | ServerHttpRequest.Builder mutate = request.mutate(); |
| | | |
| | | HttpMethod method = request.getMethod(); |
| | | if(method != HttpMethod.POST){ |
| | | return chain.filter(exchange.mutate().request(mutate.build()).build()); |
| | | } |
| | | String sing = request.getHeaders().getFirst(TokenConstants.SING); |
| | | String nonce_str = request.getHeaders().getFirst(TokenConstants.NONCE_STR); |
| | | // if (parameter_signature && StringUtils.isEmpty(sing)) { |
| | | // return unauthorizedResponse(exchange, "签名不能为空!"); |
| | | // } |
| | | // if (parameter_signature && StringUtils.isEmpty(nonce_str)) { |
| | | // return unauthorizedResponse(exchange, "签名不能为空!"); |
| | | // } |
| | | if(parameter_signature){ |
| | | return authSign(exchange, chain, sing, nonce_str); |
| | | } |
| | | return chain.filter(exchange.mutate().request(mutate.build()).build()); |
| | | } |
| | | |
| | | |
| | | |
| | | private Mono<Void> unauthorizedResponse(ServerWebExchange exchange, String msg) { |
| | | log.error("[签名异常处理]请求路径:{}", exchange.getRequest().getPath()); |
| | | return ServletUtils.webFluxResponseWriter(exchange.getResponse(), msg, HttpStatus.BAD_REQUEST); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 校验签名 |
| | | * @return |
| | | */ |
| | | private Mono<Void> authSign(ServerWebExchange exchange, GatewayFilterChain chain, String sing, String nonce_str){ |
| | | return DataBufferUtils.join(exchange.getRequest().getBody()) |
| | | .flatMap(dataBuffer -> { |
| | | byte[] bytes = new byte[dataBuffer.readableByteCount()]; |
| | | dataBuffer.read(bytes); |
| | | String bodyString = new String(bytes, StandardCharsets.UTF_8); |
| | | log.info("请求参数:{}", bodyString); |
| | | if(!authSign(JSON.parseObject(bodyString), sing, nonce_str)){ |
| | | return unauthorizedResponse(exchange, "签名验证失败!"); |
| | | } |
| | | DataBufferUtils.release(dataBuffer); |
| | | Flux<DataBuffer> cachedFlux = Flux.defer(() -> { |
| | | DataBuffer buffer = exchange.getResponse().bufferFactory() |
| | | .wrap(bytes); |
| | | return Mono.just(buffer); |
| | | }); |
| | | ServerHttpRequest mutatedRequest = new ServerHttpRequestDecorator(exchange.getRequest()) { |
| | | @Override |
| | | public Flux<DataBuffer> getBody() { |
| | | return cachedFlux; |
| | | } |
| | | }; |
| | | return chain.filter(exchange.mutate().request(mutatedRequest) |
| | | .build()); |
| | | }); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 签名校验 |
| | | * @return |
| | | */ |
| | | private boolean authSign(JSONObject jsonStr, String sign, String nonce_str) { |
| | | String signUrlEncode = localSignUrl(jsonStr, nonce_str); |
| | | signUrlEncode = signUrlEncode.replaceAll("& #40;", "\\(") |
| | | .replaceAll("& #41;", "\\)") |
| | | .replaceAll("\\+", " "); |
| | | if(sign.equals(signUrlEncode)){ |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 组装签名路径 |
| | | * @param params |
| | | * @return |
| | | */ |
| | | public static String localSignUrl(JSONObject params, String key) { |
| | | List<String> keySet = new ArrayList<>(params.keySet()); |
| | | // 对所有传入参数按照字段名的 ASCII 码从小到大排序(字典序) |
| | | Collections.sort(keySet, new Comparator<String>() { |
| | | @Override |
| | | public int compare(String o1, String o2) { |
| | | return o1.compareTo(o2); |
| | | } |
| | | }); |
| | | // 构造签名键值对的格式 |
| | | StringBuilder sb = new StringBuilder(); |
| | | for (String k : keySet) { |
| | | String v = params.getString(k); |
| | | if(StringUtils.isNotEmpty(v)){ |
| | | sb.append(k + "=" + v + "&"); |
| | | } |
| | | } |
| | | String signUrl = sb.substring(0, sb.length() - 1); |
| | | return signUrlEncode(signUrl, key); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 签名字符串加密 |
| | | * @param signUrl |
| | | * @param encryptKey |
| | | * @return |
| | | */ |
| | | public static String signUrlEncode(String signUrl, String encryptKey) { |
| | | byte[] signByte = new byte[0]; |
| | | try { |
| | | signByte = HMACSHA1.HmacSHA1Encrypt(signUrl, encryptKey); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | throw new RuntimeException(e); |
| | | } |
| | | String localSign = Base64.encodeBase64String(signByte); |
| | | return localSign; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public int getOrder() |
| | | { |
| | | return -200; |
| | | } |
| | | } |
| | |
| | | // 跨站脚本的 xss 配置,nacos自行添加 |
| | | @Autowired |
| | | private XssProperties xss; |
| | | |
| | | @Value("${security.sign}") |
| | | private boolean parameter_signature; |
| | | |
| | | @Override |
| | | public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) |
| | | { |
| | | public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) { |
| | | ServerHttpRequest request = exchange.getRequest(); |
| | | // xss开关未开启 或 通过nacos关闭,不过滤 |
| | | if (!xss.getEnabled()) |
| | | { |
| | | if (!xss.getEnabled()) { |
| | | return chain.filter(exchange); |
| | | } |
| | | // GET DELETE 不过滤 |
| | | HttpMethod method = request.getMethod(); |
| | | if (method == null || method == HttpMethod.GET || method == HttpMethod.DELETE) |
| | | { |
| | | if (method == null || method == HttpMethod.GET || method == HttpMethod.DELETE) { |
| | | return chain.filter(exchange); |
| | | } |
| | | // 非json类型,不过滤 |
| | | if (!isJsonRequest(exchange)) |
| | | { |
| | | if (!isJsonRequest(exchange)) { |
| | | return chain.filter(exchange); |
| | | } |
| | | // excludeUrls 不过滤 |
| | | String url = request.getURI().getPath(); |
| | | if (StringUtils.matches(url, xss.getExcludeUrls())) |
| | | { |
| | | if (StringUtils.matches(url, xss.getExcludeUrls())) { |
| | | return chain.filter(exchange); |
| | | } |
| | | ServerHttpRequestDecorator httpRequestDecorator = requestDecorator(exchange); |
| | | if(parameter_signature && !authSign(httpRequestDecorator)){ |
| | | log.error("[鉴权签名异常处理]请求路径:{}", exchange.getRequest().getPath()); |
| | | return ServletUtils.webFluxResponseWriter(exchange.getResponse(), "签名校验失败", HttpStatus.BAD_REQUEST); |
| | | } |
| | | return chain.filter(exchange.mutate().request(httpRequestDecorator).build()); |
| | | |
| | | } |
| | | |
| | | private ServerHttpRequestDecorator requestDecorator(ServerWebExchange exchange) |
| | | { |
| | | ServerHttpRequestDecorator serverHttpRequestDecorator = new ServerHttpRequestDecorator(exchange.getRequest()) |
| | | { |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | private ServerHttpRequestDecorator requestDecorator(ServerWebExchange exchange) { |
| | | ServerHttpRequestDecorator serverHttpRequestDecorator = new ServerHttpRequestDecorator(exchange.getRequest()) { |
| | | @Override |
| | | public Flux<DataBuffer> getBody() |
| | | { |
| | | public Flux<DataBuffer> getBody() { |
| | | Flux<DataBuffer> body = super.getBody(); |
| | | return body.buffer().map(dataBuffers -> { |
| | | DataBufferFactory dataBufferFactory = new DefaultDataBufferFactory(); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public HttpHeaders getHeaders() |
| | | { |
| | | public HttpHeaders getHeaders() { |
| | | HttpHeaders httpHeaders = new HttpHeaders(); |
| | | httpHeaders.putAll(super.getHeaders()); |
| | | // 由于修改了请求体的body,导致content-length长度不确定,因此需要删除原先的content-length |
| | |
| | | * |
| | | * @param exchange HTTP请求 |
| | | */ |
| | | public boolean isJsonRequest(ServerWebExchange exchange) |
| | | { |
| | | public boolean isJsonRequest(ServerWebExchange exchange) { |
| | | String header = exchange.getRequest().getHeaders().getFirst(HttpHeaders.CONTENT_TYPE); |
| | | return StringUtils.startsWithIgnoreCase(header, MediaType.APPLICATION_JSON_VALUE); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 签名校验 |
| | | * @param httpRequestDecorator |
| | | * @return |
| | | */ |
| | | private boolean authSign(ServerHttpRequestDecorator httpRequestDecorator) { |
| | | HttpHeaders headers = httpRequestDecorator.getHeaders(); |
| | | AtomicReference<JSONObject> jsonObject = new AtomicReference<>(new JSONObject()); |
| | | httpRequestDecorator.getBody().buffer().map(dataBuffers -> { |
| | | DataBufferFactory dataBufferFactory = new DefaultDataBufferFactory(); |
| | | DataBuffer join = dataBufferFactory.join(dataBuffers); |
| | | byte[] content = new byte[join.readableByteCount()]; |
| | | join.read(content); |
| | | DataBufferUtils.release(join); |
| | | String bodyStr = new String(content, StandardCharsets.UTF_8); |
| | | jsonObject.set(JSON.parseObject(bodyStr)); |
| | | |
| | | // 防xss攻击过滤 |
| | | bodyStr = EscapeUtil.clean(bodyStr); |
| | | // 转成字节 |
| | | byte[] bytes = bodyStr.getBytes(); |
| | | NettyDataBufferFactory nettyDataBufferFactory = new NettyDataBufferFactory(ByteBufAllocator.DEFAULT); |
| | | DataBuffer buffer = nettyDataBufferFactory.allocateBuffer(bytes.length); |
| | | buffer.write(bytes); |
| | | return buffer; |
| | | }); |
| | | JSONObject params = jsonObject.get(); |
| | | String sign = headers.getFirst(TokenConstants.SING); |
| | | if(StringUtils.isEmpty(sign)){ |
| | | return false; |
| | | } |
| | | String nonce_str = headers.getFirst(TokenConstants.NONCE_STR); |
| | | if(StringUtils.isEmpty(nonce_str)){ |
| | | return false; |
| | | } |
| | | |
| | | String signUrlEncode = localSignUrl(params, nonce_str); |
| | | signUrlEncode = signUrlEncode.replaceAll("& #40;", "\\(") |
| | | .replaceAll("& #41;", "\\)") |
| | | .replaceAll("\\+", " "); |
| | | if(sign.equals(signUrlEncode)){ |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 组装签名路径 |
| | | * @param params |
| | | * @return |
| | | */ |
| | | public static String localSignUrl(JSONObject params, String key) { |
| | | List<String> keySet = new ArrayList<>(params.keySet()); |
| | | // 对所有传入参数按照字段名的 ASCII 码从小到大排序(字典序) |
| | | Collections.sort(keySet, new Comparator<String>() { |
| | | @Override |
| | | public int compare(String o1, String o2) { |
| | | return o1.compareTo(o2); |
| | | } |
| | | }); |
| | | // 构造签名键值对的格式 |
| | | StringBuilder sb = new StringBuilder(); |
| | | for (String k : keySet) { |
| | | String v = params.getString(k); |
| | | if(StringUtils.isNotEmpty(v)){ |
| | | sb.append(k + "=" + v + "&"); |
| | | } |
| | | } |
| | | String signUrl = sb.substring(0, sb.length() - 1); |
| | | return signUrlEncode(signUrl, key); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 签名字符串加密 |
| | | * @param signUrl |
| | | * @param encryptKey |
| | | * @return |
| | | */ |
| | | public static String signUrlEncode(String signUrl, String encryptKey) { |
| | | byte[] signByte = new byte[0]; |
| | | try { |
| | | signByte = HMACSHA1.HmacSHA1Encrypt(signUrl, encryptKey); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | String localSign = Base64.encodeBase64String(signByte); |
| | | return localSign; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public int getOrder() |
| | |
| | | } |
| | | |
| | | @PostMapping("/updateSysUser") |
| | | @Transactional(propagation = Propagation.REQUIRES_NEW) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R<Boolean> updateSysUser(@RequestBody SysUser sysUser) { |
| | | try { |
| | | sysUser.setUpdateBy(SecurityUtils.getUsername()); |
| | |
| | | .last("LIMIT 1")); |
| | | return R.ok(user); |
| | | } |
| | | |
| | | /** |
| | | * 根据账号获取用户数据 |
| | | * @param account |
| | | * @return |
| | | */ |
| | | @PostMapping("/queryUserByAccount") |
| | | public R<SysUser> queryUserByAccount(@RequestBody String account){ |
| | | SysUser user = userService.getOne(Wrappers.lambdaQuery(SysUser.class) |
| | | .eq(SysUser::getAccount, account) |
| | | .eq(SysUser::getDelFlag, "0")); |
| | | return R.ok(user); |
| | | } |
| | | |
| | | |
| | | /** |
| | |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/addSysUser") |
| | | @Transactional(propagation = Propagation.REQUIRES_NEW) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R addSysUser(@RequestBody SysUser user){ |
| | | user.setUserName(user.getPhonenumber()); |
| | | if(!org.springframework.util.StringUtils.hasLength(user.getNickName())){ |
| | |
| | | if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) { |
| | | throw new RuntimeException("手机号已开通账号"); |
| | | } |
| | | if (StringUtils.isNotEmpty(user.getAccount()) && !userService.checkAccountUnique(user)) { |
| | | if (StringUtils.isNotEmpty(user.getUserName()) && !userService.checkUserNameUnique(user)) { |
| | | throw new RuntimeException("登录账号已存在"); |
| | | } |
| | | user.setCreateBy(SecurityUtils.getUsername()); |
| | |
| | | */ |
| | | public SysUser checkPhoneUnique(String phonenumber); |
| | | |
| | | /** |
| | | * 校验登录账号是否唯一 |
| | | * @param account 登录账号 |
| | | * @return |
| | | */ |
| | | SysUser checkAccountUnique(String account); |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | * @return 结果 |
| | | */ |
| | | public boolean checkPhoneUnique(SysUser user); |
| | | |
| | | boolean checkAccountUnique(SysUser user); |
| | | |
| | | /** |
| | | * 校验email是否唯一 |
| | |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public boolean checkAccountUnique(SysUser user) { |
| | | SysUser info = userMapper.checkAccountUnique(user.getAccount()); |
| | | if (StringUtils.isNotNull(info) ) |
| | | { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | | return UserConstants.UNIQUE; |
| | | } |
| | | |
| | | /** |
| | | * 校验email是否唯一 |
| | | * |
| | |
| | | <result property="phonenumber" column="phonenumber" /> |
| | | <result property="sex" column="sex" /> |
| | | <result property="avatar" column="avatar" /> |
| | | <result property="account" column="account" /> |
| | | <result property="password" column="password" /> |
| | | <result property="status" column="status" /> |
| | | <result property="delFlag" column="del_flag" /> |
| | |
| | | |
| | | <select id="checkPhoneUnique" parameterType="String" resultMap="SysUserResult"> |
| | | select user_id, phonenumber from sys_user where phonenumber = #{phonenumber} and del_flag = '0' limit 1 |
| | | </select> |
| | | |
| | | |
| | | <select id="checkAccountUnique" resultMap="SysUserResult"> |
| | | select user_id, account from sys_user where account = #{account} and del_flag = '0' limit 1 |
| | | </select> |
| | | |
| | | <select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult"> |
| | |
| | | name: ruoyi-account |
| | | main: |
| | | allow-bean-definition-overriding: true |
| | | allow-circular-references: true |
| | | profiles: |
| | | # 环境配置 |
| | | active: dev |
| | |
| | | <artifactId>spring-boot-starter-test</artifactId> |
| | | <scope>test</scope> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-api-other</artifactId> |
| | | <version>3.6.2</version> |
| | | <scope>compile</scope> |
| | | </dependency> |
| | | |
| | | </dependencies> |
| | | |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
| | | import com.ruoyi.chargingPile.api.dto.GetPermissionConfigurationDTO; |
| | | import com.ruoyi.chargingPile.api.dto.PartnerListDTO; |
| | | import com.ruoyi.chargingPile.api.model.Partner; |
| | | import com.ruoyi.chargingPile.api.query.GetPartnerList; |
| | | import com.ruoyi.chargingPile.api.query.SetPermissionConfiguration; |
| | | import com.ruoyi.chargingPile.dto.ResetPassword; |
| | | import com.ruoyi.chargingPile.service.IPartnerService; |
| | | 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.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | |
| | | @Resource |
| | | private IPartnerService partnerService; |
| | | |
| | | @Resource |
| | | private SysUserClient sysUserClient; |
| | | |
| | | |
| | | |
| | | |
| | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/getPartner") |
| | | @GetMapping("/getPartner") |
| | | @ApiOperation(value = "获取所有合作商", tags = {"管理后台-站点管理"}) |
| | | public AjaxResult<List<Partner>> getPartner(){ |
| | | List<Partner> list = partnerService.list(new LambdaQueryWrapper<Partner>().eq(Partner::getDelFlag, 0)); |
| | | SysUser sysUser = sysUserClient.getSysUser(SecurityUtils.getUserId()).getData(); |
| | | Integer roleType = sysUser.getRoleType(); |
| | | Integer objectId = sysUser.getObjectId(); |
| | | LambdaQueryWrapper<Partner> wrapper = new LambdaQueryWrapper<Partner>().eq(Partner::getDelFlag, 0); |
| | | if(2 == roleType){ |
| | | wrapper.eq(Partner::getId, objectId); |
| | | } |
| | | List<Partner> list = partnerService.list(wrapper); |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @GetMapping("/getPermissionConfiguration/{siteId}") |
| | | @ApiOperation(value = "获取合作商权限设置", tags = {"管理后台-站点管理"}) |
| | | public AjaxResult<GetPermissionConfigurationDTO> getPermissionConfiguration(@PathVariable("siteId") Integer siteId, @RequestParam("partnerId") Integer partnerId){ |
| | | GetPermissionConfigurationDTO permissionConfiguration = partnerService.getPermissionConfiguration(siteId, partnerId); |
| | | return AjaxResult.success(permissionConfiguration); |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/setPermissionConfiguration/{siteId}") |
| | | @ApiOperation(value = "设置合作商权限", tags = {"管理后台-站点管理"}) |
| | | public AjaxResult setPermissionConfiguration(@RequestBody SetPermissionConfiguration req){ |
| | | partnerService.setPermissionConfiguration(req); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.ruoyi.chargingPile.api.dto.GetSiteListDTO; |
| | | 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.query.GetSiteList; |
| | | import com.ruoyi.chargingPile.api.query.SiteDetailQuery; |
| | | import com.ruoyi.chargingPile.api.query.SiteQuery; |
| | | import com.ruoyi.chargingPile.api.vo.ChargingGunCountVO; |
| | | import com.ruoyi.chargingPile.api.vo.SiteDetailVO; |
| | | import com.ruoyi.chargingPile.api.vo.SiteVO; |
| | | import com.ruoyi.chargingPile.api.vo.TChargingPileVO; |
| | | import com.ruoyi.chargingPile.domain.SiteMenu; |
| | | import com.ruoyi.chargingPile.service.IPartnerService; |
| | | import com.ruoyi.chargingPile.service.ISiteService; |
| | | import com.ruoyi.chargingPile.service.TChargingGunService; |
| | | import com.ruoyi.chargingPile.service.TChargingPileService; |
| | | 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.other.api.feignClient.RoleSiteClient; |
| | | import com.ruoyi.other.api.feignClient.UserSiteClient; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | |
| | | |
| | | @Resource |
| | | private ISiteService siteService; |
| | | |
| | | @Resource |
| | | private IPartnerService partnerService; |
| | | |
| | | @Resource |
| | | private SysUserClient sysUserClient; |
| | | |
| | | @Resource |
| | | private UserSiteClient userSiteClient; |
| | | |
| | | @Resource |
| | | private RoleSiteClient roleSiteClient; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @Autowired |
| | | private TChargingPileService chargingPileService; |
| | | @Autowired |
| | | private TChargingGunService chargingGunService; |
| | | |
| | | @ResponseBody |
| | | @GetMapping("/getSiteList") |
| | |
| | | @PostMapping("/pageList") |
| | | public AjaxResult<PageInfo<SiteVO>> pageList(@Validated @RequestBody SiteQuery query){ |
| | | return AjaxResult.success(siteService.pageList(query)); |
| | | } |
| | | |
| | | @ApiOperation(value = "获取站点详细信息", tags = {"小程序-站点管理-站点详情"}) |
| | | @PostMapping("/getDetailById") |
| | | public AjaxResult<SiteDetailVO> getDetailById(@Validated @RequestBody SiteDetailQuery query){ |
| | | SiteDetailVO siteDetailVO = siteService.getDetailById(query.getSiteId()); |
| | | // 计算距离 |
| | | Map<String, Double> distance = GeodesyUtil.getDistance(query.getLat() + "," + query.getLon(), siteDetailVO.getLat() + "," + siteDetailVO.getLon()); |
| | | siteDetailVO.setDistance(distance.get("WGS84")); |
| | | // TODO 查询绑定车牌提示文案 |
| | | return AjaxResult.success(siteDetailVO); |
| | | } |
| | | |
| | | @ApiOperation(value = "获取站点下充电桩及充电枪列表", tags = {"小程序-站点管理-站点详情"}) |
| | | @GetMapping("/getChargingGunList") |
| | | public AjaxResult<List<TChargingPileVO>> getChargingGunList(@RequestParam(value = "siteId")@ApiParam(value = "站点id", required = true)Integer siteId, |
| | | @RequestParam(value = "siteId",required = false)@ApiParam(value = "类型 1=超充,2=快充,3=慢充")Integer type){ |
| | | return AjaxResult.success(chargingPileService.getChargingGunList(siteId)); |
| | | } |
| | | |
| | | @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)); |
| | | } |
| | | |
| | | |
| | |
| | | @GetMapping("/getAllSiteList") |
| | | @ApiOperation(value = "获取所有站点数据", tags = {"管理后台-充电桩信息"}) |
| | | public AjaxResult<List<Site>> getAllSiteList(){ |
| | | List<Site> list = siteService.list(new LambdaQueryWrapper<Site>().eq(Site::getDelFlag, 0) |
| | | .orderByDesc(Site::getCreateTime)); |
| | | //校验当前账户站点权限 |
| | | SysUser sysUser = sysUserClient.getSysUser(SecurityUtils.getUserId()).getData(); |
| | | Integer roleType = sysUser.getRoleType(); |
| | | Integer objectId = sysUser.getObjectId(); |
| | | LambdaQueryWrapper<Site> wrapper = new LambdaQueryWrapper<Site>().eq(Site::getDelFlag, 0); |
| | | if(2 == roleType){ |
| | | Set<Integer> list = partnerService.authSite(objectId, SiteMenu.SITE_LIST); |
| | | wrapper.in(Site::getId, list); |
| | | }else{ |
| | | //非管理员需要根据角色和用户配置查询允许的站点数据 |
| | | if(!SecurityUtils.isAdmin(SecurityUtils.getUserId())){ |
| | | List<Integer> data = userSiteClient.getSiteIds(sysUser.getUserId()).getData(); |
| | | List<Integer> data1 = roleSiteClient.getSiteIds(sysUser.getRoleId()).getData(); |
| | | data.addAll(data1); |
| | | Set<Integer> list = new HashSet<>(data); |
| | | wrapper.in(Site::getId, list); |
| | | } |
| | | } |
| | | List<Site> list = siteService.list(wrapper.orderByDesc(Site::getCreateTime)); |
| | | return AjaxResult.success(list); |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.common.log.annotation.Log; |
| | | import com.ruoyi.common.log.enums.BusinessType; |
| | | import com.ruoyi.common.log.enums.OperatorType; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | /** |
| | | * 添加计费策略管理 |
| | | */ |
| | | @Log(title = "添加计费策略", businessType = BusinessType.INSERT,operatorType = OperatorType.MANAGE) |
| | | @ApiOperation(tags = {"后台-计费策略", "管理后台-站点管理"},value = "添加计费策略") |
| | | @PostMapping(value = "/add") |
| | | public AjaxResult<Integer> add(@RequestBody TAccountingStrategyDTO dto) { |
| | |
| | | /** |
| | | * 修改计费策略 |
| | | */ |
| | | @Log(title = "修改计费策略", businessType = BusinessType.UPDATE,operatorType = OperatorType.MANAGE) |
| | | @ApiOperation(tags = {"后台-计费策略", "管理后台-站点管理"},value = "修改计费策略") |
| | | @PostMapping(value = "/update") |
| | | public AjaxResult<Boolean> update(@RequestBody TAccountingStrategyDTO dto) { |
| | |
| | | /** |
| | | * 删除计费策略 |
| | | */ |
| | | @Log(title = "删除计费策略", businessType = BusinessType.DELETE,operatorType = OperatorType.MANAGE) |
| | | @ApiOperation(tags = {"后台-计费策略"},value = "删除计费策略") |
| | | @DeleteMapping(value = "/deleteById") |
| | | public AjaxResult<Boolean> deleteById(@RequestParam Integer id) { |
| | |
| | | /** |
| | | * 批量删除计费策略 |
| | | */ |
| | | @Log(title = "批量删除计费策略", businessType = BusinessType.DELETE,operatorType = OperatorType.MANAGE) |
| | | @ApiOperation(tags = {"后台-计费策略"},value = "批量删除计费策略") |
| | | @DeleteMapping(value = "/deleteByIds") |
| | | public AjaxResult<Boolean> deleteByIds(@RequestBody List<Integer> ids) { |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | import com.ruoyi.chargingPile.service.TCarportService; |
| | | import com.ruoyi.chargingPile.service.TVehicleRampService; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.log.annotation.Log; |
| | | import com.ruoyi.common.log.enums.BusinessType; |
| | | import com.ruoyi.common.log.enums.OperatorType; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | /** |
| | | * 建桩申请 |
| | | */ |
| | | @ApiOperation(tags = {"小程序-建桩申请","后台-申请表单-申请建桩-添加"},value = "建桩申请") |
| | | @Log(title = "建桩申请", businessType = BusinessType.INSERT,operatorType = OperatorType.MOBILE) |
| | | @ApiOperation(tags = {"小程序-建桩申请"},value = "建桩申请") |
| | | @PostMapping(value = "/add") |
| | | public AjaxResult<Boolean> add(@RequestBody TApplyChargingPile dto) { |
| | | // TODO 用户id |
| | |
| | | import com.ruoyi.chargingPile.service.TCarportService; |
| | | import com.ruoyi.chargingPile.service.TVehicleRampService; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.log.annotation.Log; |
| | | import com.ruoyi.common.log.enums.BusinessType; |
| | | import com.ruoyi.common.log.enums.OperatorType; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | /** |
| | | * 添加车库管理 |
| | | */ |
| | | @Log(title = "添加车库", businessType = BusinessType.INSERT,operatorType = OperatorType.MANAGE) |
| | | @ApiOperation(tags = {"后台-车库"},value = "添加车库") |
| | | @PostMapping(value = "/add") |
| | | public AjaxResult<Boolean> add(@RequestBody TCarport dto) { |
| | |
| | | /** |
| | | * 修改车库 |
| | | */ |
| | | @Log(title = "修改车库", businessType = BusinessType.INSERT,operatorType = OperatorType.MANAGE) |
| | | @ApiOperation(tags = {"后台-车库"},value = "修改车库") |
| | | @PostMapping(value = "/update") |
| | | public AjaxResult<Boolean> update(@RequestBody TCarport dto) { |
| | |
| | | /** |
| | | * 删除车库 |
| | | */ |
| | | @Log(title = "删除车库", businessType = BusinessType.DELETE,operatorType = OperatorType.MANAGE) |
| | | @ApiOperation(tags = {"后台-车库"},value = "删除车库") |
| | | @DeleteMapping(value = "/deleteById") |
| | | public AjaxResult<Boolean> deleteById(@RequestParam Integer id) { |
| | |
| | | /** |
| | | * 批量删除车库 |
| | | */ |
| | | @Log(title = "批量删除车库", businessType = BusinessType.DELETE,operatorType = OperatorType.MANAGE) |
| | | @ApiOperation(tags = {"后台-车库"},value = "批量删除车库") |
| | | @DeleteMapping(value = "/deleteByIds") |
| | | public AjaxResult<Boolean> deleteByIds(@RequestBody List<Integer> ids) { |
| | |
| | | import com.ruoyi.chargingPile.service.TChargingGunService; |
| | | 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 io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | /** |
| | | * 添加充电枪管理 |
| | | */ |
| | | @Log(title = "添加充电枪", businessType = BusinessType.INSERT,operatorType = OperatorType.MANAGE) |
| | | @ApiOperation(tags = {"管理后台-充电桩信息"},value = "添加充电枪") |
| | | @PostMapping(value = "/add") |
| | | public AjaxResult add(@RequestBody TChargingGunDTO dto) { |
| | |
| | | /** |
| | | * 修改充电枪 |
| | | */ |
| | | @Log(title = "修改充电枪", businessType = BusinessType.UPDATE,operatorType = OperatorType.MANAGE) |
| | | @ApiOperation(tags = {"管理后台-充电桩信息"},value = "修改充电枪") |
| | | @PostMapping(value = "/update") |
| | | public AjaxResult update(@RequestBody TChargingGunDTO dto) { |
| | |
| | | /** |
| | | * 删除充电枪 |
| | | */ |
| | | @Log(title = "删除充电枪", businessType = BusinessType.DELETE,operatorType = OperatorType.MANAGE) |
| | | @ApiOperation(tags = {"管理后台-充电桩信息"},value = "删除充电枪") |
| | | @DeleteMapping(value = "/deleteById") |
| | | public AjaxResult<Boolean> deleteById(@RequestParam Integer id) { |
| | |
| | | /** |
| | | * 批量删除充电枪 |
| | | */ |
| | | @Log(title = "批量删除充电枪", businessType = BusinessType.DELETE,operatorType = OperatorType.MANAGE) |
| | | @ApiOperation(tags = {"后台-充电枪"},value = "批量删除充电枪") |
| | | @DeleteMapping(value = "/deleteByIds") |
| | | public AjaxResult<Boolean> deleteByIds(@RequestBody List<Integer> ids) { |
| | |
| | | /** |
| | | * 结束充电 |
| | | */ |
| | | @Log(title = "结束充电", businessType = BusinessType.UPDATE,operatorType = OperatorType.MANAGE) |
| | | @ApiOperation(tags = {"后台-充电枪"},value = "结束充电") |
| | | @PostMapping(value = "/stopCharging") |
| | | public AjaxResult<String> stopCharging() { |
| | |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.chargingPile.api.query.PageChargingPileList; |
| | | import com.ruoyi.common.log.annotation.Log; |
| | | import com.ruoyi.common.log.enums.BusinessType; |
| | | import com.ruoyi.common.log.enums.OperatorType; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | |
| | | */ |
| | | @ApiOperation(tags = {"小程序-充电桩"},value = "查询充电桩列表") |
| | | @PostMapping(value = "/list") |
| | | public AjaxResult<List<TChargingPile>> list(@RequestParam(name = "siteId",value = "站点id",required = false)Integer siteId) { |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "siteId", value = "站点id") |
| | | }) |
| | | public AjaxResult<List<TChargingPile>> list(@RequestParam("siteId") Integer siteId) { |
| | | return AjaxResult.ok(chargingPileService.list(Wrappers.lambdaQuery(TChargingPile.class) |
| | | .eq(TChargingPile::getSiteId,siteId))); |
| | | } |
| | |
| | | } |
| | | |
| | | @ResponseBody |
| | | @Log(title = "添加充电桩数据", businessType = BusinessType.INSERT,operatorType = OperatorType.MANAGE) |
| | | @PostMapping("/addChargingPile") |
| | | @ApiOperation(value = "添加充电桩数据", tags = {"管理后台-充电桩信息"}) |
| | | public AjaxResult addChargingPile(@RequestBody TChargingPile chargingPile){ |
| | |
| | | |
| | | |
| | | @ResponseBody |
| | | @Log(title = "编辑充电桩数据", businessType = BusinessType.UPDATE,operatorType = OperatorType.MANAGE) |
| | | @PostMapping("/editChargingPile") |
| | | @ApiOperation(value = "编辑充电桩数据", tags = {"管理后台-充电桩信息"}) |
| | | public AjaxResult editChargingPile(@RequestBody TChargingPile chargingPile){ |
| | |
| | | |
| | | @ResponseBody |
| | | @DeleteMapping("/delChargingPile/{id}") |
| | | @Log(title = "删除充电桩", businessType = BusinessType.DELETE,operatorType = OperatorType.MANAGE) |
| | | @ApiOperation(value = "删除充电桩", tags = {"管理后台-充电桩信息"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "充电桩id", name = "id", dataTypeClass = Integer.class, required = true) |
| | |
| | | |
| | | |
| | | @ResponseBody |
| | | @Log(title = "批量设置计费策略", businessType = BusinessType.UPDATE,operatorType = OperatorType.MANAGE) |
| | | @PostMapping("/batchSetAccountingStrategy") |
| | | @ApiOperation(value = "批量设置计费策略", tags = {"管理后台-充电桩信息"}) |
| | | public AjaxResult batchSetAccountingStrategy(@RequestBody BatchSetAccountingStrategy setAccountingStrategy){ |
| | |
| | | import com.ruoyi.chargingPile.service.TChargingPileService; |
| | | import com.ruoyi.chargingPile.service.TFaultMessageService; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.log.annotation.Log; |
| | | import com.ruoyi.common.log.enums.BusinessType; |
| | | import com.ruoyi.common.log.enums.OperatorType; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | |
| | | /** |
| | | * 添加故障报修管理 |
| | | */ |
| | | @Log(title = "添加故障报修管理", businessType = BusinessType.INSERT,operatorType = OperatorType.MOBILE) |
| | | @ApiOperation(tags = {"小程序-故障报修"},value = "添加故障报修管理") |
| | | @PostMapping(value = "/add") |
| | | public AjaxResult<Boolean> add(@Validated @RequestBody TFaultMessage dto) { |
| | |
| | | import com.ruoyi.chargingPile.service.TMonitoringEquipmentService; |
| | | 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 io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | /** |
| | | * 添加监控管理 |
| | | */ |
| | | @Log(title = "添加监控", businessType = BusinessType.INSERT,operatorType = OperatorType.MANAGE) |
| | | @ApiOperation(tags = {"后台-监控"},value = "添加监控") |
| | | @PostMapping(value = "/add") |
| | | public AjaxResult<Boolean> add(@RequestBody TMonitoringEquipmentDTO dto) { |
| | |
| | | /** |
| | | * 修改监控 |
| | | */ |
| | | @Log(title = "修改监控", businessType = BusinessType.UPDATE,operatorType = OperatorType.MANAGE) |
| | | @ApiOperation(tags = {"后台-监控"},value = "修改监控") |
| | | @PostMapping(value = "/update") |
| | | public AjaxResult<Boolean> update(@RequestBody TMonitoringEquipmentDTO dto) { |
| | |
| | | /** |
| | | * 删除监控 |
| | | */ |
| | | @Log(title = "删除监控", businessType = BusinessType.DELETE,operatorType = OperatorType.MANAGE) |
| | | @ApiOperation(tags = {"后台-监控"},value = "删除监控") |
| | | @DeleteMapping(value = "/deleteById") |
| | | public AjaxResult<Boolean> deleteById(@RequestParam Integer id) { |
| | |
| | | /** |
| | | * 批量删除监控 |
| | | */ |
| | | @Log(title = "批量删除监控", businessType = BusinessType.DELETE,operatorType = OperatorType.MANAGE) |
| | | @ApiOperation(tags = {"后台-监控"},value = "批量删除监控") |
| | | @DeleteMapping(value = "/deleteByIds") |
| | | public AjaxResult<Boolean> deleteByIds(@RequestBody List<Integer> ids) { |
| | |
| | | import com.ruoyi.chargingPile.service.TVehicleRampService; |
| | | 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 io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | /** |
| | | * 添加停车场管理 |
| | | */ |
| | | @Log(title = "添加停车场", businessType = BusinessType.INSERT,operatorType = OperatorType.MANAGE) |
| | | @ApiOperation(tags = {"后台-停车场"},value = "添加停车场") |
| | | @PostMapping(value = "/add") |
| | | public AjaxResult<Boolean> add(@RequestBody TParkingLotDTO dto) { |
| | |
| | | /** |
| | | * 修改停车场 |
| | | */ |
| | | @Log(title = "修改停车场", businessType = BusinessType.UPDATE,operatorType = OperatorType.MANAGE) |
| | | @ApiOperation(tags = {"后台-停车场"},value = "修改停车场") |
| | | @PostMapping(value = "/update") |
| | | public AjaxResult<Boolean> update(@RequestBody TParkingLotDTO dto) { |
| | |
| | | /** |
| | | * 删除停车场 |
| | | */ |
| | | @Log(title = "删除停车场", businessType = BusinessType.DELETE,operatorType = OperatorType.MANAGE) |
| | | @ApiOperation(tags = {"后台-停车场"},value = "删除停车场") |
| | | @DeleteMapping(value = "/deleteById") |
| | | public AjaxResult<Boolean> deleteById(@RequestParam Integer id) { |
| | |
| | | /** |
| | | * 批量删除停车场 |
| | | */ |
| | | @Log(title = "批量删除停车场", businessType = BusinessType.DELETE,operatorType = OperatorType.MANAGE) |
| | | @ApiOperation(tags = {"后台-停车场"},value = "批量删除停车场") |
| | | @DeleteMapping(value = "/deleteByIds") |
| | | public AjaxResult<Boolean> deleteByIds(@RequestBody List<Integer> ids) { |
| | |
| | | import com.ruoyi.chargingPile.api.model.TVehicleRamp; |
| | | import com.ruoyi.chargingPile.service.TVehicleRampService; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.log.annotation.Log; |
| | | import com.ruoyi.common.log.enums.BusinessType; |
| | | import com.ruoyi.common.log.enums.OperatorType; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | /** |
| | | * 添加车道管理 |
| | | */ |
| | | @Log(title = "添加车道", businessType = BusinessType.INSERT,operatorType = OperatorType.MANAGE) |
| | | @ApiOperation(tags = {"后台-车道"},value = "添加车道") |
| | | @PostMapping(value = "/add") |
| | | public AjaxResult<Boolean> add(@RequestBody TVehicleRamp dto) { |
| | |
| | | /** |
| | | * 修改车道 |
| | | */ |
| | | @Log(title = "修改车道", businessType = BusinessType.UPDATE,operatorType = OperatorType.MANAGE) |
| | | @ApiOperation(tags = {"后台-车道"},value = "修改车道") |
| | | @PostMapping(value = "/update") |
| | | public AjaxResult<Boolean> update(@RequestBody TVehicleRamp dto) { |
| | |
| | | /** |
| | | * 删除车道 |
| | | */ |
| | | @Log(title = "删除车道", businessType = BusinessType.DELETE,operatorType = OperatorType.MANAGE) |
| | | @ApiOperation(tags = {"后台-车道"},value = "删除车道") |
| | | @DeleteMapping(value = "/deleteById") |
| | | public AjaxResult<Boolean> deleteById(@RequestParam Integer id) { |
| | |
| | | /** |
| | | * 批量删除车道 |
| | | */ |
| | | @Log(title = "批量删除车道", businessType = BusinessType.DELETE,operatorType = OperatorType.MANAGE) |
| | | @ApiOperation(tags = {"后台-车道"},value = "批量删除车道") |
| | | @DeleteMapping(value = "/deleteByIds") |
| | | public AjaxResult<Boolean> deleteByIds(@RequestBody List<Integer> ids) { |
| | |
| | | /** |
| | | * 开关闸车道 |
| | | */ |
| | | @Log(title = "开关闸车道", businessType = BusinessType.UPDATE,operatorType = OperatorType.MANAGE) |
| | | @ApiOperation(tags = {"后台-车道"},value = "开关闸车道") |
| | | @PostMapping(value = "/openOrDown") |
| | | public AjaxResult<String> openOrDown(@RequestBody TVehicleRamp dto) { |
New file |
| | |
| | | package com.ruoyi.chargingPile.domain; |
| | | |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2024/8/9 15:28 |
| | | */ |
| | | public enum SiteMenu { |
| | | //站点管理 |
| | | SITE_LIST("/data/site"), |
| | | //站点计费策略 |
| | | SITE_ACCOUNTING_STRATEGY("/data/site/accounting_strategy"), |
| | | //站点编辑 |
| | | SITE_UPDATE("/data/site/update"), |
| | | //站点删除 |
| | | SITE_DELETE("/data/site/delete"), |
| | | //充电桩信息 |
| | | CHARGING_PILE("/data/charging_pile"), |
| | | //充电桩查看 |
| | | CHARGING_PILE_QUERY_INFO("/data/charging_pile/query_info"), |
| | | //充电桩编辑 |
| | | CHARGING_PILE_UPDATE("/data/charging_pile/update"), |
| | | //充电桩删除 |
| | | CHARGING_PILE_DELETE("/data/charging_pile/delete"), |
| | | //充电桩新增接口 |
| | | CHARGING_PILE_ADD_CHARGING_GUN("/data/charging_pile/add_charging_gun"), |
| | | //接口信息 |
| | | CHARGING_GUN("/data/charging_gun"), |
| | | //接口编辑 |
| | | CHARGING_GUN_UPDATE("/data/charging_gun/update"), |
| | | //接口删除 |
| | | CHARGING_GUN_DELETE("/data/charging_gun/delete"), |
| | | //接口查看费率 |
| | | CHARGING_GUN_VIEW_RATES("/data/charging_gun/view_rates"), |
| | | //接口下载二维码 |
| | | CHARGING_GUN_DOWNLOAD_QR_CODE("/data/charging_gun/download_qr_code"), |
| | | //接口查看详情 |
| | | CHARGING_GUN_QUERY_INFO("/data/charging_gun/query_info"), |
| | | //接口结束充电 |
| | | CHARGING_GUN_END_CHARGE("/data/charging_gun/end_charge"), |
| | | //停车场配置 |
| | | PARKING_LOT("/data/parking_lot"), |
| | | //停车场查看 |
| | | PARKING_LOT_QUERY_INFO("/data/parking_lot/query_info"), |
| | | //停车场编辑 |
| | | PARKING_LOT_UPDATE("/data/parking_lot/update"), |
| | | //停车场删除 |
| | | PARKING_LOT_DELETE("/data/parking_lot/delete"), |
| | | //停车场监控 |
| | | PARKING_LOT_MONITOR("/data/parking_lot/monitor"), |
| | | //停车场新增车库 |
| | | PARKING_LOT_ADD_GARAGE("/data/parking_lot/add_garage"), |
| | | //监控管理 |
| | | MONITOR("/data/monitor"), |
| | | //监控查看 |
| | | MONITOR_QUERY_INFO("/data/monitor/query_info"), |
| | | ; |
| | | private String value; |
| | | |
| | | |
| | | SiteMenu(String value) { |
| | | this.value = value; |
| | | } |
| | | |
| | | public String getValue() { |
| | | return value; |
| | | } |
| | | |
| | | public void setValue(String value) { |
| | | this.value = value; |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.chargingPile.api.model.Site; |
| | | import com.ruoyi.chargingPile.api.query.GetSiteList; |
| | | import com.ruoyi.chargingPile.api.query.SiteQuery; |
| | | import com.ruoyi.chargingPile.api.vo.SiteDetailVO; |
| | | import com.ruoyi.chargingPile.api.vo.SiteVO; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | |
| | | * @param siteList |
| | | * @return |
| | | */ |
| | | List<GetSiteListDTO> getSiteList(PageInfo<GetSiteListDTO> pageInfo, @Param("item") GetSiteList siteList); |
| | | List<GetSiteListDTO> getSiteList(PageInfo<GetSiteListDTO> pageInfo, @Param("item") GetSiteList siteList, @Param("ids") Set<Integer> ids); |
| | | |
| | | /** |
| | | * 获取站点分页列表 |
| | |
| | | */ |
| | | List<SiteVO> pageList(@Param("query")SiteQuery query,@Param("pageInfo")PageInfo<SiteVO> pageInfo); |
| | | |
| | | /** |
| | | * 获取站点详情 |
| | | * @param siteId |
| | | * @return |
| | | */ |
| | | SiteDetailVO getDetailById(@Param("siteId")Integer siteId); |
| | | |
| | | } |
| | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @param pageInfo |
| | | * @return |
| | | */ |
| | | List<TChargingGunVO> pageList(@Param("query") TChargingGunQuery query, @Param("pageInfo")PageInfo<TChargingGunVO> pageInfo); |
| | | List<TChargingGunVO> pageList(@Param("query") TChargingGunQuery query, @Param("pageInfo")PageInfo<TChargingGunVO> pageInfo, @Param("siteIds") Set<Integer> siteIds); |
| | | |
| | | } |
| | |
| | | import com.ruoyi.chargingPile.api.dto.PageChargingPileListDTO; |
| | | import com.ruoyi.chargingPile.api.model.TChargingPile; |
| | | import com.ruoyi.chargingPile.api.query.PageChargingPileList; |
| | | import com.ruoyi.chargingPile.api.vo.TChargingPileVO; |
| | | 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.Set; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @param page |
| | | * @return |
| | | */ |
| | | List<PageChargingPileListDTO> pageChargingPileList(PageInfo<PageChargingPileListDTO> pageInfo, @Param("item") PageChargingPileList page); |
| | | List<PageChargingPileListDTO> pageChargingPileList(PageInfo<PageChargingPileListDTO> pageInfo, @Param("item") PageChargingPileList page, @Param("siteIds") Set<Integer> siteIds); |
| | | |
| | | |
| | | /** |
| | |
| | | * @return |
| | | */ |
| | | TChargingPile getChargingPile(Integer id); |
| | | |
| | | /** |
| | | * 获取站点下充电桩及充电枪列表 |
| | | * @param siteId |
| | | * @return |
| | | */ |
| | | List<TChargingPileVO> getChargingGunList(@Param("siteId")Integer siteId); |
| | | } |
| | |
| | | package com.ruoyi.chargingPile.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.chargingPile.api.dto.GetPermissionConfigurationDTO; |
| | | import com.ruoyi.chargingPile.api.dto.PartnerListDTO; |
| | | import com.ruoyi.chargingPile.api.model.Partner; |
| | | import com.ruoyi.chargingPile.api.query.GetPartnerList; |
| | | import com.ruoyi.chargingPile.api.query.SetPermissionConfiguration; |
| | | import com.ruoyi.chargingPile.domain.SiteMenu; |
| | | import com.ruoyi.chargingPile.dto.ResetPassword; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | |
| | | * @param resetPassword |
| | | */ |
| | | AjaxResult resetPassword(ResetPassword resetPassword); |
| | | |
| | | |
| | | /** |
| | | * 获取合作商权限 |
| | | * @param siteId |
| | | * @return |
| | | */ |
| | | GetPermissionConfigurationDTO getPermissionConfiguration(Integer siteId, Integer partnerId); |
| | | |
| | | /** |
| | | * 合作商权限配置 |
| | | * @param req |
| | | */ |
| | | void setPermissionConfiguration(SetPermissionConfiguration req); |
| | | |
| | | |
| | | /** |
| | | * 获取合作商授权的站点数据 |
| | | * @param siteMenu 授权菜单路径枚举类 |
| | | * @return |
| | | */ |
| | | Set<Integer> authSite(Integer partnerId, SiteMenu siteMenu); |
| | | |
| | | |
| | | /** |
| | | * 判断当前账户是否有权限 |
| | | * @param siteId 站点id |
| | | * @param siteMenu 菜单路径枚举类 |
| | | * @return |
| | | */ |
| | | boolean authMenu(Integer partnerId, Integer siteId, SiteMenu siteMenu); |
| | | } |
| | |
| | | import com.ruoyi.chargingPile.api.model.Site; |
| | | import com.ruoyi.chargingPile.api.query.GetSiteList; |
| | | import com.ruoyi.chargingPile.api.query.SiteQuery; |
| | | import com.ruoyi.chargingPile.api.vo.SiteDetailVO; |
| | | import com.ruoyi.chargingPile.api.vo.SiteVO; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | |
| | | * @param accountingStrategyId 计费策略id |
| | | */ |
| | | void setAccountingStrategy(Integer id, Integer accountingStrategyId); |
| | | |
| | | |
| | | /** |
| | | * 获取站点分页列表 |
| | | * @param query |
| | | * @return |
| | | */ |
| | | |
| | | PageInfo<SiteVO> pageList(SiteQuery query); |
| | | |
| | | /** |
| | | * 获取站点详情 |
| | | * @param siteId |
| | | * @return |
| | | */ |
| | | SiteDetailVO getDetailById(Integer siteId); |
| | | } |
| | |
| | | import com.ruoyi.chargingPile.api.dto.TChargingGunDTO; |
| | | 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.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.Map; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @return |
| | | */ |
| | | AjaxResult update(TChargingGunDTO dto); |
| | | |
| | | /** |
| | | * 获取站点下充电枪数量统计 |
| | | * @param siteId |
| | | * @return |
| | | */ |
| | | Map<String, ChargingGunCountVO> getChargingGunCount(Integer siteId); |
| | | } |
| | |
| | | import com.ruoyi.chargingPile.api.model.TChargingPile; |
| | | import com.ruoyi.chargingPile.api.query.BatchSetAccountingStrategy; |
| | | import com.ruoyi.chargingPile.api.query.PageChargingPileList; |
| | | import com.ruoyi.chargingPile.api.vo.TChargingPileVO; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @param setAccountingStrategy |
| | | */ |
| | | void batchSetAccountingStrategy(BatchSetAccountingStrategy setAccountingStrategy); |
| | | |
| | | /** |
| | | * 获取站点下充电桩及充电枪列表 |
| | | * @param siteId |
| | | * @return |
| | | */ |
| | | List<TChargingPileVO> getChargingGunList(Integer siteId); |
| | | |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.chargingPile.api.dto.GetPermissionConfigurationDTO; |
| | | import com.ruoyi.chargingPile.api.dto.PartnerListDTO; |
| | | import com.ruoyi.chargingPile.api.model.Partner; |
| | | import com.ruoyi.chargingPile.api.model.Site; |
| | | import com.ruoyi.chargingPile.api.model.*; |
| | | import com.ruoyi.chargingPile.api.query.GetPartnerList; |
| | | import com.ruoyi.chargingPile.api.query.SetPermissionConfiguration; |
| | | import com.ruoyi.chargingPile.domain.SiteMenu; |
| | | import com.ruoyi.chargingPile.dto.ResetPassword; |
| | | import com.ruoyi.chargingPile.mapper.PartnerMapper; |
| | | import com.ruoyi.chargingPile.service.IPartnerService; |
| | | import com.ruoyi.chargingPile.service.ISiteService; |
| | | import com.ruoyi.chargingPile.service.*; |
| | | import com.ruoyi.common.core.domain.R; |
| | | 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.security.utils.SecurityUtils; |
| | | import com.ruoyi.other.api.feignClient.RoleSiteClient; |
| | | import com.ruoyi.other.api.feignClient.UserSiteClient; |
| | | import com.ruoyi.system.api.domain.SysRole; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.feignClient.SysRoleClient; |
| | |
| | | import io.seata.spring.annotation.GlobalTransactional; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | |
| | | @Resource |
| | | private ISiteService siteService; |
| | | |
| | | @Resource |
| | | private TPartnerSiteService partnerSiteService; |
| | | |
| | | @Resource |
| | | private TSiteMenuService siteMenuService; |
| | | |
| | | @Resource |
| | | private TChargingPileService chargingPileService; |
| | | |
| | | @Resource |
| | | private UserSiteClient userSiteClient; |
| | | |
| | | @Resource |
| | | private RoleSiteClient roleSiteClient; |
| | | |
| | | |
| | | |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | @GlobalTransactional//分布式事务 |
| | | @GlobalTransactional(rollbackFor = Exception.class)//分布式事务 |
| | | public AjaxResult addPartner(Partner partner) { |
| | | //校验参数和重复数据 |
| | | AjaxResult ajaxResult = addPartnerParameterCheck(partner); |
| | |
| | | this.save(partner); |
| | | //添加登录账户 |
| | | SysUser user = new SysUser(); |
| | | user.setAccount(partner.getAccount()); |
| | | user.setPhonenumber(partner.getPhoneOne()); |
| | | user.setUserName(partner.getName()); |
| | | user.setUserName(partner.getAccount()); |
| | | user.setNickName(partner.getName()); |
| | | user.setAvatar(partner.getLogoUrl()); |
| | | user.setPassword(partner.getPassword()); |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | @GlobalTransactional//分布式事务 |
| | | @GlobalTransactional(rollbackFor = Exception.class)//分布式事务 |
| | | public AjaxResult editPartner(Partner partner) { |
| | | //校验参数和重复数据 |
| | | AjaxResult ajaxResult = addPartnerParameterCheck(partner); |
| | |
| | | return AjaxResult.error("登录账号不能重复"); |
| | | } |
| | | Partner oldPartner = this.getById(partner.getId()); |
| | | SysUser user = sysUserClient.queryUserByAccount(oldPartner.getAccount()).getData(); |
| | | SysUser user = sysUserClient.queryUserByUserName(oldPartner.getAccount()).getData(); |
| | | |
| | | //修改数据 |
| | | this.updateById(partner); |
| | |
| | | user = new SysUser(); |
| | | user.setStatus("0"); |
| | | user.setDelFlag("0"); |
| | | user.setAccount(partner.getAccount()); |
| | | user.setPhonenumber(partner.getPhoneOne()); |
| | | user.setUserName(partner.getName()); |
| | | user.setUserName(partner.getAccount()); |
| | | user.setNickName(partner.getName()); |
| | | user.setAvatar(partner.getLogoUrl()); |
| | | user.setPassword(partner.getPassword()); |
| | |
| | | throw new RuntimeException(r.getMsg()); |
| | | } |
| | | }else{ |
| | | user.setAccount(partner.getAccount()); |
| | | user.setPhonenumber(partner.getPhoneOne()); |
| | | user.setUserName(partner.getName()); |
| | | user.setUserName(partner.getAccount()); |
| | | user.setNickName(partner.getName()); |
| | | user.setAvatar(partner.getLogoUrl()); |
| | | user.setPassword(partner.getPassword()); |
| | |
| | | * @param id 合作商id |
| | | */ |
| | | @Override |
| | | @GlobalTransactional//分布式事务 |
| | | @GlobalTransactional(rollbackFor = Exception.class)//分布式事务 |
| | | public AjaxResult delPartner(Integer id) { |
| | | //查询有无关联数据 |
| | | //站点 |
| | | long count = siteService.count(new LambdaQueryWrapper<Site>().eq(Site::getPartnerId, id).eq(Site::getDelFlag, 0)); |
| | | if(count > 0){ |
| | | return AjaxResult.error("当前合作商有关联得站点,删除失败!"); |
| | | return AjaxResult.error("当前合作商有关联站点,删除失败!"); |
| | | } |
| | | // todo 代码完善 |
| | | //充电桩 |
| | | long count1 = chargingPileService.count(new LambdaQueryWrapper<TChargingPile>().eq(TChargingPile::getPartnerId, id).eq(TChargingPile::getDelFlag, 0)); |
| | | if(count1 > 0){ |
| | | return AjaxResult.error("当前合作商有关联充电桩,删除失败!"); |
| | | } |
| | | |
| | | Partner partner = this.getById(id); |
| | | if(null == partner){ |
| | |
| | | } |
| | | partner.setDelFlag(true); |
| | | this.updateById(partner); |
| | | SysUser user = sysUserClient.queryUserByAccount(partner.getAccount()).getData(); |
| | | SysUser user = sysUserClient.queryUserByUserName(partner.getAccount()).getData(); |
| | | user.setDelFlag("2"); |
| | | sysUserClient.updateUser(user); |
| | | return AjaxResult.success(); |
| | |
| | | * @param resetPassword |
| | | */ |
| | | @Override |
| | | @GlobalTransactional//分布式事务 |
| | | @GlobalTransactional(rollbackFor = Exception.class)//分布式事务 |
| | | public AjaxResult resetPassword(ResetPassword resetPassword) { |
| | | if(null == resetPassword.getId()){ |
| | | return AjaxResult.error("合作商id不能为空"); |
| | |
| | | partner.setPassword(resetPassword.getPassword()); |
| | | this.updateById(partner); |
| | | //修改登录账号的密码 |
| | | SysUser user = sysUserClient.queryUserByAccount(partner.getAccount()).getData(); |
| | | SysUser user = sysUserClient.queryUserByUserName(partner.getAccount()).getData(); |
| | | user.setPassword(partner.getPassword()); |
| | | sysUserClient.resetPassword(user); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取合作商权限 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public GetPermissionConfigurationDTO getPermissionConfiguration(Integer siteId, Integer partnerId) { |
| | | Partner partner = this.getById(partnerId); |
| | | GetPermissionConfigurationDTO dto = new GetPermissionConfigurationDTO(); |
| | | dto.setPermissionRemarks(partner.getPermissionRemarks()); |
| | | Map<String, Object> menu = new HashMap<>(); |
| | | List<TPartnerSite> list = partnerSiteService.list(new LambdaQueryWrapper<TPartnerSite>() |
| | | .eq(TPartnerSite::getPartnerId, partnerId) |
| | | .eq(TPartnerSite::getSiteId, siteId)); |
| | | List<Integer> collect = list.stream().map(TPartnerSite::getSiteMenuId).collect(Collectors.toList()); |
| | | List<TSiteMenu> tSiteMenus = siteMenuService.list(new LambdaQueryWrapper<TSiteMenu>() |
| | | .eq(TSiteMenu::getParentId, 0) |
| | | .eq(TSiteMenu::getVisible, 0) |
| | | .eq(TSiteMenu::getStatus, 0).orderByAsc(TSiteMenu::getOrderNum)); |
| | | for (TSiteMenu tSiteMenu : tSiteMenus) { |
| | | menu.put("id", tSiteMenu.getMenuId()); |
| | | menu.put("name", tSiteMenu.getMenuName()); |
| | | menu.put("path", tSiteMenu.getPath()); |
| | | menu.put("type", tSiteMenu.getMenuType()); |
| | | |
| | | List<TSiteMenu> tSiteMenus1 = siteMenuService.list(new LambdaQueryWrapper<TSiteMenu>() |
| | | .eq(TSiteMenu::getParentId, tSiteMenu.getMenuId()) |
| | | .eq(TSiteMenu::getVisible, 0) |
| | | .eq(TSiteMenu::getStatus, 0).orderByAsc(TSiteMenu::getOrderNum)); |
| | | Map<String, Object> child = new HashMap<>(); |
| | | for (TSiteMenu siteMenu : tSiteMenus1) { |
| | | child.put("id", siteMenu.getMenuId()); |
| | | child.put("name", siteMenu.getMenuName()); |
| | | child.put("path", siteMenu.getPath()); |
| | | child.put("type", siteMenu.getMenuType()); |
| | | child.put("selected", collect.contains(siteMenu.getMenuId())); |
| | | } |
| | | menu.put("selected", child.keySet().size() > 0 ? true : false); |
| | | menu.put("child", child); |
| | | } |
| | | dto.setMenu(menu); |
| | | return dto; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 合作商权限配置 |
| | | * @param req |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void setPermissionConfiguration(SetPermissionConfiguration req) { |
| | | //删除原始配置 |
| | | partnerSiteService.remove(new LambdaQueryWrapper<TPartnerSite>().eq(TPartnerSite::getPartnerId, req.getPartnerId()).eq(TPartnerSite::getSiteId, req.getSiteId())); |
| | | //添加新的配置 |
| | | List<TPartnerSite> sites = new ArrayList<>(); |
| | | List<Integer> list = req.getMenuId(); |
| | | for (Integer integer : list) { |
| | | TPartnerSite partnerSite = new TPartnerSite(); |
| | | partnerSite.setPartnerId(req.getPartnerId()); |
| | | partnerSite.setSiteId(req.getSiteId()); |
| | | partnerSite.setSiteMenuId(integer); |
| | | sites.add(partnerSite); |
| | | } |
| | | partnerSiteService.saveBatch(sites); |
| | | //修改权限配置 |
| | | Partner partner = this.getById(req.getPartnerId()); |
| | | partner.setPermissionRemarks(req.getPermissionRemarks()); |
| | | this.updateById(partner); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取合作商授权的站点数据 |
| | | * @param siteMenu 授权菜单路径枚举类 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Set<Integer> authSite(Integer partnerId, SiteMenu siteMenu) { |
| | | TSiteMenu one = siteMenuService.getOne(new LambdaQueryWrapper<TSiteMenu>().eq(TSiteMenu::getPath, siteMenu.getValue()).eq(TSiteMenu::getStatus, 0)); |
| | | List<TPartnerSite> list = partnerSiteService.list(new LambdaQueryWrapper<TPartnerSite>() |
| | | .eq(TPartnerSite::getPartnerId, partnerId) |
| | | .eq(TPartnerSite::getSiteMenuId, one.getMenuId())); |
| | | List<Integer> collect = list.stream().map(TPartnerSite::getSiteId).collect(Collectors.toList()); |
| | | //获取合作商用户关联的站点数据 |
| | | Partner partner = this.getById(partnerId); |
| | | SysUser sysUser = sysUserClient.queryUserByUserName(partner.getAccount()).getData(); |
| | | List<Integer> data = userSiteClient.getSiteIds(sysUser.getUserId()).getData(); |
| | | List<Integer> data1 = roleSiteClient.getSiteIds(sysUser.getRoleId()).getData(); |
| | | collect.addAll(data); |
| | | collect.addAll(data1); |
| | | Set<Integer> siteIds = new HashSet<>(collect); |
| | | if(siteIds.size() == 0){ |
| | | siteIds.add(-1); |
| | | } |
| | | return siteIds; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 判断当前账户是否有权限 |
| | | * @param siteId 站点id |
| | | * @param siteMenu 菜单路径枚举类 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean authMenu(Integer partnerId, Integer siteId, SiteMenu siteMenu) { |
| | | TSiteMenu one = siteMenuService.getOne(new LambdaQueryWrapper<TSiteMenu>().eq(TSiteMenu::getPath, siteMenu.getValue()).eq(TSiteMenu::getStatus, 0)); |
| | | TPartnerSite partnerSite = partnerSiteService.getOne(new LambdaQueryWrapper<TPartnerSite>() |
| | | .eq(TPartnerSite::getPartnerId, partnerId) |
| | | .eq(TPartnerSite::getSiteMenuId, one.getMenuId()) |
| | | .eq(TPartnerSite::getSiteId, siteId)); |
| | | return null == partnerSite ? false : true; |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.chargingPile.api.dto.GetSiteListDTO; |
| | | 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.query.GetSiteList; |
| | | import com.ruoyi.chargingPile.api.query.SiteQuery; |
| | | import com.ruoyi.chargingPile.api.vo.SiteDetailVO; |
| | | import com.ruoyi.chargingPile.api.vo.SiteVO; |
| | | import com.ruoyi.chargingPile.api.vo.TAccountingStrategyVO; |
| | | import com.ruoyi.chargingPile.domain.SiteMenu; |
| | | import com.ruoyi.chargingPile.mapper.SiteMapper; |
| | | import com.ruoyi.chargingPile.service.IPartnerService; |
| | | import com.ruoyi.chargingPile.service.ISiteService; |
| | | import com.ruoyi.chargingPile.service.TChargingGunService; |
| | | import com.ruoyi.chargingPile.service.TChargingPileService; |
| | | 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.security.utils.SecurityUtils; |
| | | import com.ruoyi.other.api.feignClient.RoleSiteClient; |
| | | import com.ruoyi.other.api.feignClient.UserSiteClient; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Propagation; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | |
| | | @Resource |
| | | private TChargingGunService chargingGunService; |
| | | |
| | | @Resource |
| | | private TChargingPileService chargingPileService; |
| | | |
| | | @Resource |
| | | private SysUserClient sysUserClient; |
| | | |
| | | @Resource |
| | | private IPartnerService partnerService; |
| | | |
| | | @Resource |
| | | private UserSiteClient userSiteClient; |
| | | |
| | | @Resource |
| | | private RoleSiteClient roleSiteClient; |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public PageInfo<GetSiteListDTO> getSiteList(GetSiteList siteList) { |
| | | Set<Integer> ids = null; |
| | | //校验合作商权限 |
| | | SysUser sysUser = sysUserClient.getSysUser(SecurityUtils.getUserId()).getData(); |
| | | Integer roleType = sysUser.getRoleType(); |
| | | Integer objectId = sysUser.getObjectId(); |
| | | //合作商 |
| | | if(roleType == 2){ |
| | | ids = partnerService.authSite(objectId, SiteMenu.SITE_LIST); |
| | | }else{ |
| | | //非管理员需要根据角色和用户配置查询允许的站点数据 |
| | | if(!SecurityUtils.isAdmin(SecurityUtils.getUserId())){ |
| | | List<Integer> data = userSiteClient.getSiteIds(sysUser.getUserId()).getData(); |
| | | List<Integer> data1 = roleSiteClient.getSiteIds(sysUser.getRoleId()).getData(); |
| | | data.addAll(data1); |
| | | ids = new HashSet<>(data); |
| | | } |
| | | } |
| | | PageInfo<GetSiteListDTO> pageInfo = new PageInfo<>(siteList.getPageCurr(), siteList.getPageSize()); |
| | | List<GetSiteListDTO> list = this.baseMapper.getSiteList(pageInfo, siteList); |
| | | List<GetSiteListDTO> list = this.baseMapper.getSiteList(pageInfo, siteList, ids); |
| | | for (GetSiteListDTO getSiteListDTO : list) { |
| | | Integer siteId = getSiteListDTO.getId(); |
| | | getSiteListDTO.setAuthAccountingStrategy(roleType == 1 ? true : partnerService.authMenu(objectId, siteId, SiteMenu.SITE_ACCOUNTING_STRATEGY)); |
| | | //平台账号才有此权限 |
| | | getSiteListDTO.setAuthPartner(roleType == 1 ? true : false); |
| | | getSiteListDTO.setAuthUpdate(roleType == 1 ? true : partnerService.authMenu(objectId, siteId, SiteMenu.SITE_UPDATE)); |
| | | getSiteListDTO.setAuthDelete(roleType == 1 ? true : partnerService.authMenu(objectId, siteId, SiteMenu.SITE_DELETE)); |
| | | } |
| | | return pageInfo.setRecords(list); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 添加站点信息 |
| | |
| | | public AjaxResult delSite(Integer id) { |
| | | //查询是否有关联数据 |
| | | //充电桩 |
| | | // todo 待完善 |
| | | long count1 = chargingPileService.count(new LambdaQueryWrapper<TChargingPile>().eq(TChargingPile::getSiteId, id).eq(TChargingPile::getDelFlag, 0)); |
| | | if(count1 > 0){ |
| | | return AjaxResult.error("该站点有关联充电桩,删除失败!"); |
| | | } |
| | | Site site = this.getById(id); |
| | | site.setDelFlag(true); |
| | | this.updateById(site); |
| | |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public SiteDetailVO getDetailById(Integer siteId) { |
| | | return this.baseMapper.getDetailById(siteId); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 设置站点计费策略 |
| | | * @param id 站点id |
| | | * @param accountingStrategyId 计费策略id |
| | | */ |
| | | @Override |
| | | @Transactional(propagation = Propagation.REQUIRES_NEW) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void setAccountingStrategy(Integer id, Integer accountingStrategyId) { |
| | | Site site = this.getById(id); |
| | | site.setAccountingStrategyId(accountingStrategyId); |
| | |
| | | package com.ruoyi.chargingPile.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.chargingPile.api.dto.TChargingGunDTO; |
| | | 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.TChargingGunVO; |
| | | import com.ruoyi.chargingPile.api.vo.TMonitoringEquipmentVO; |
| | | import com.ruoyi.chargingPile.domain.SiteMenu; |
| | | import com.ruoyi.chargingPile.mapper.TChargingGunMapper; |
| | | import com.ruoyi.chargingPile.service.IPartnerService; |
| | | import com.ruoyi.chargingPile.service.TChargingGunService; |
| | | import com.ruoyi.common.core.enums.status.ChargingGunModeEnum; |
| | | import com.ruoyi.common.core.enums.status.ChargingGunStatusEnum; |
| | | 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.security.utils.SecurityUtils; |
| | | import com.ruoyi.other.api.feignClient.RoleSiteClient; |
| | | import com.ruoyi.other.api.feignClient.UserSiteClient; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | 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.stream.Collectors; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | @Service |
| | | public class TChargingGunServiceImpl extends ServiceImpl<TChargingGunMapper, TChargingGun> implements TChargingGunService { |
| | | |
| | | @Resource |
| | | private SysUserClient sysUserClient; |
| | | |
| | | @Resource |
| | | private IPartnerService partnerService; |
| | | |
| | | @Resource |
| | | private UserSiteClient userSiteClient; |
| | | |
| | | @Resource |
| | | private RoleSiteClient roleSiteClient; |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public PageInfo<TChargingGunVO> pageList(TChargingGunQuery query) { |
| | | Set<Integer> siteIds = null; |
| | | //校验合作商权限 |
| | | SysUser sysUser = sysUserClient.getSysUser(SecurityUtils.getUserId()).getData(); |
| | | Integer roleType = sysUser.getRoleType(); |
| | | Integer objectId = sysUser.getObjectId(); |
| | | //合作商 |
| | | if(roleType == 2){ |
| | | siteIds = partnerService.authSite(objectId, SiteMenu.CHARGING_GUN); |
| | | }else{ |
| | | //非管理员需要根据角色和用户配置查询允许的站点数据 |
| | | if(!SecurityUtils.isAdmin(SecurityUtils.getUserId())){ |
| | | List<Integer> data = userSiteClient.getSiteIds(sysUser.getUserId()).getData(); |
| | | List<Integer> data1 = roleSiteClient.getSiteIds(sysUser.getRoleId()).getData(); |
| | | data.addAll(data1); |
| | | siteIds = new HashSet<>(data); |
| | | } |
| | | } |
| | | PageInfo<TChargingGunVO> pageInfo = new PageInfo<>(query.getPageCurr(),query.getPageSize()); |
| | | List<TChargingGunVO> list = this.baseMapper.pageList(query,pageInfo); |
| | | List<TChargingGunVO> list = this.baseMapper.pageList(query,pageInfo, siteIds); |
| | | for (TChargingGunVO tChargingGunVO : list) { |
| | | Integer siteId = tChargingGunVO.getSiteId(); |
| | | tChargingGunVO.setAuthDelete(roleType == 1 ? true : partnerService.authMenu(objectId, siteId, SiteMenu.CHARGING_GUN_DELETE)); |
| | | tChargingGunVO.setAuthDownloadQRCode(roleType == 1 ? true : partnerService.authMenu(objectId, siteId, SiteMenu.CHARGING_GUN_DOWNLOAD_QR_CODE)); |
| | | tChargingGunVO.setAuthEndCharge(roleType == 1 ? true : partnerService.authMenu(objectId, siteId, SiteMenu.CHARGING_GUN_END_CHARGE)); |
| | | tChargingGunVO.setAuthQueryInfo(roleType == 1 ? true : partnerService.authMenu(objectId, siteId, SiteMenu.CHARGING_GUN_QUERY_INFO)); |
| | | tChargingGunVO.setAuthUpdate(roleType == 1 ? true : partnerService.authMenu(objectId, siteId, SiteMenu.CHARGING_GUN_UPDATE)); |
| | | tChargingGunVO.setAuthViewRates(roleType == 1 ? true : partnerService.authMenu(objectId, siteId, SiteMenu.CHARGING_GUN_VIEW_RATES)); |
| | | } |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public AjaxResult update(TChargingGunDTO dto) { |
| | | TChargingGun chargingGun = this.getById(dto.getId()); |
| | | if(Arrays.asList(3,4,5,6).contains(chargingGun.getStatus())){ |
| | | return AjaxResult.error("接口占用中,无法编辑!"); |
| | | } |
| | | AjaxResult ajaxResult = addVerify(dto); |
| | | if(ajaxResult.isError()){ |
| | | return ajaxResult; |
| | |
| | | this.updateById(dto); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Map<String, ChargingGunCountVO> getChargingGunCount(Integer siteId) { |
| | | Map<String, ChargingGunCountVO> map = new HashMap<>(4); |
| | | // 查询全部充电枪 |
| | | List<TChargingGun> list = this.list(Wrappers.lambdaQuery(TChargingGun.class).eq(TChargingGun::getSiteId, siteId)); |
| | | int freeCount = 0; |
| | | // 超级充 |
| | | ChargingGunCountVO superSufficient = getGunCount(ChargingGunModeEnum.SUPER_SUFFICIENT.getCode(), list); |
| | | freeCount += superSufficient.getFreeCount(); |
| | | map.put("superSufficient", superSufficient); |
| | | // 快充 |
| | | ChargingGunCountVO fastSufficient = getGunCount(ChargingGunModeEnum.FAST_SUFFICIENT.getCode(), list); |
| | | freeCount += fastSufficient.getFreeCount(); |
| | | map.put("fastSufficient", fastSufficient); |
| | | // 慢充 |
| | | ChargingGunCountVO slowSufficient = getGunCount(ChargingGunModeEnum.SLOW_SUFFICIENT.getCode(), list); |
| | | freeCount += slowSufficient.getFreeCount(); |
| | | map.put("slowSufficient", slowSufficient); |
| | | ChargingGunCountVO chargingGunCountVO = new ChargingGunCountVO(); |
| | | chargingGunCountVO.setTotalCount(list.size()); |
| | | chargingGunCountVO.setFreeCount(freeCount); |
| | | map.put("totalSufficient", chargingGunCountVO); |
| | | return map; |
| | | } |
| | | |
| | | 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()); |
| | | chargingGunCountVO.setFreeCount(list.stream().filter(tChargingGun -> tChargingGun.getChargeMode().equals(chargeMode) |
| | | && tChargingGun.getStatus()== ChargingGunStatusEnum.IDLE.getCode()).collect(Collectors.toList()).size()); |
| | | return chargingGunCountVO; |
| | | } |
| | | |
| | | /** |
| | | * 校验必填项 |
| | | * @param dto |
| | |
| | | package com.ruoyi.chargingPile.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.chargingPile.api.dto.PageChargingPileListDTO; |
| | | import com.ruoyi.chargingPile.api.model.TChargingGun; |
| | | import com.ruoyi.chargingPile.api.model.TChargingPile; |
| | | import com.ruoyi.chargingPile.api.query.BatchSetAccountingStrategy; |
| | | import com.ruoyi.chargingPile.api.query.PageChargingPileList; |
| | | import com.ruoyi.chargingPile.api.vo.TChargingGunVO; |
| | | import com.ruoyi.chargingPile.api.vo.TChargingPileVO; |
| | | import com.ruoyi.chargingPile.domain.SiteMenu; |
| | | import com.ruoyi.chargingPile.mapper.TChargingPileMapper; |
| | | import com.ruoyi.chargingPile.service.IPartnerService; |
| | | import com.ruoyi.chargingPile.service.TChargingGunService; |
| | | import com.ruoyi.chargingPile.service.TChargingPileService; |
| | | 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.security.utils.SecurityUtils; |
| | | import com.ruoyi.other.api.feignClient.RoleSiteClient; |
| | | import com.ruoyi.other.api.feignClient.UserSiteClient; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | @Resource |
| | | private TChargingGunService chargingGunService; |
| | | |
| | | @Resource |
| | | private SysUserClient sysUserClient; |
| | | |
| | | @Resource |
| | | private IPartnerService partnerService; |
| | | |
| | | @Resource |
| | | private UserSiteClient userSiteClient; |
| | | |
| | | @Resource |
| | | private RoleSiteClient roleSiteClient; |
| | | |
| | | |
| | | |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public PageInfo<PageChargingPileListDTO> pageChargingPileList(PageChargingPileList page) { |
| | | Set<Integer> siteIds = null; |
| | | //校验合作商权限 |
| | | SysUser sysUser = sysUserClient.getSysUser(SecurityUtils.getUserId()).getData(); |
| | | Integer roleType = sysUser.getRoleType(); |
| | | Integer objectId = sysUser.getObjectId(); |
| | | //合作商 |
| | | if(roleType == 2){ |
| | | siteIds = partnerService.authSite(objectId, SiteMenu.CHARGING_PILE); |
| | | }else{ |
| | | //非管理员需要根据角色和用户配置查询允许的站点数据 |
| | | if(!SecurityUtils.isAdmin(SecurityUtils.getUserId())){ |
| | | List<Integer> data = userSiteClient.getSiteIds(sysUser.getUserId()).getData(); |
| | | List<Integer> data1 = roleSiteClient.getSiteIds(sysUser.getRoleId()).getData(); |
| | | data.addAll(data1); |
| | | siteIds = new HashSet<>(data); |
| | | } |
| | | } |
| | | PageInfo<PageChargingPileListDTO> pageInfo = new PageInfo<>(page.getPageCurr(), page.getPageSize()); |
| | | List<PageChargingPileListDTO> list = this.baseMapper.pageChargingPileList(pageInfo, page); |
| | | List<PageChargingPileListDTO> list = this.baseMapper.pageChargingPileList(pageInfo, page, siteIds); |
| | | for (PageChargingPileListDTO pageChargingPileListDTO : list) { |
| | | Integer siteId = pageChargingPileListDTO.getSiteId(); |
| | | pageChargingPileListDTO.setAuthAddChargingGun(roleType == 1 ? true : partnerService.authMenu(objectId, siteId, SiteMenu.CHARGING_PILE_ADD_CHARGING_GUN)); |
| | | pageChargingPileListDTO.setAuthDelete(roleType == 1 ? true : partnerService.authMenu(objectId, siteId, SiteMenu.CHARGING_PILE_DELETE)); |
| | | pageChargingPileListDTO.setAuthQueryInfo(roleType == 1 ? true : partnerService.authMenu(objectId, siteId, SiteMenu.CHARGING_PILE_QUERY_INFO)); |
| | | pageChargingPileListDTO.setAuthUpdate(roleType == 1 ? true : partnerService.authMenu(objectId, siteId, SiteMenu.CHARGING_PILE_UPDATE)); |
| | | } |
| | | return pageInfo.setRecords(list); |
| | | } |
| | | |
| | |
| | | } |
| | | chargingGunService.updateBatchById(list); |
| | | } |
| | | |
| | | @Override |
| | | public List<TChargingPileVO> getChargingGunList(Integer siteId) { |
| | | List<TChargingPileVO> chargingPileVOS = this.baseMapper.getChargingGunList(siteId); |
| | | List<TChargingGun> chargingGuns = chargingGunService.list(Wrappers.lambdaQuery(TChargingGun.class) |
| | | .eq(TChargingGun::getSiteId, siteId)); |
| | | // 查询充电枪信息 |
| | | chargingPileVOS.forEach(item -> { |
| | | List<TChargingGun> gunList = chargingGuns.stream().filter(gun -> gun.getChargingPileId().equals(item.getId())).collect(Collectors.toList()); |
| | | item.setChargingGunList(gunList); |
| | | }); |
| | | return chargingPileVOS; |
| | | } |
| | | } |
| | |
| | | name: ruoyi-chargingPile |
| | | main: |
| | | allow-bean-definition-overriding: true |
| | | allow-circular-references: true |
| | | profiles: |
| | | # 环境配置 |
| | | active: dev |
| | |
| | | <result column="remark" property="remark" /> |
| | | <result column="account" property="account" /> |
| | | <result column="password" property="password" /> |
| | | <result column="permission_remarks" property="permissionRemarks"/> |
| | | <result column="create_time" property="createTime" /> |
| | | <result column="del_flag" property="delFlag" /> |
| | | </resultMap> |
| | |
| | | <if test="null != item.districtsCode and '' != item.districtsCode"> |
| | | and a.districts_code = #{item.districtsCode} |
| | | </if> |
| | | <if test="null != ids"> |
| | | and a.id in |
| | | <foreach collection="ids" item="itemm" index="index" open="(" separator="," close=")"> |
| | | #{itemm} |
| | | </foreach> |
| | | </if> |
| | | order by a.sort desc, a.create_time desc limit #{item.pageCurr}, #{item.pageSize} |
| | | </select> |
| | | |
| | |
| | | </choose> |
| | | </if> |
| | | </select> |
| | | <select id="getDetailById" resultType="com.ruoyi.chargingPile.api.vo.SiteDetailVO"> |
| | | SELECT <include refid="Base_Column_List"></include> |
| | | FROM t_site WHERE id = #{siteId} AND del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()} |
| | | </select> |
| | | </mapper> |
| | |
| | | <if test="query.chargeMode != null"> |
| | | AND tas.chargeMode = #{query.chargeMode} |
| | | </if> |
| | | <if test="null != siteIds"> |
| | | and tcg.site_id in |
| | | <foreach collection="siteIds" index="index" item="item" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> |
| | | </if> |
| | | AND tas.del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()} |
| | | </where> |
| | | ORDER BY tas.create_time DESC |
| | |
| | | <if test="null != item.type"> |
| | | and a.type = #{item.type} |
| | | </if> |
| | | <if test="null != siteIds"> |
| | | and a.site_id in |
| | | <foreach collection="siteIds" item="itemm" index="index" open="(" separator="," close=")"> |
| | | #{itemm} |
| | | </foreach> |
| | | </if> |
| | | order by a.create_time desc limit #{item.pageCurr}, #{item.pageSize} |
| | | </select> |
| | | |
| | |
| | | left join t_site b on (a.site_id = b.id) |
| | | left join t_partner c on (a.partner_id = c.id) |
| | | </select> |
| | | <select id="getChargingGunList" resultType="com.ruoyi.chargingPile.api.vo.TChargingPileVO"> |
| | | select id,code, `name`, `number` from t_charging_pile |
| | | where del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()} and site_id = #{siteId} |
| | | </select> |
| | | </mapper> |
| | |
| | | name: ruoyi-integration |
| | | main: |
| | | allow-bean-definition-overriding: true |
| | | allow-circular-references: true |
| | | profiles: |
| | | # 环境配置 |
| | | active: dev |
| | |
| | | name: ruoyi-order |
| | | main: |
| | | allow-bean-definition-overriding: true |
| | | allow-circular-references: true |
| | | profiles: |
| | | # 环境配置 |
| | | active: dev |
| | |
| | | import com.ruoyi.common.core.enums.status.AdvertisingStatusEnum; |
| | | 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.other.api.domain.TAdvertising; |
| | | import com.ruoyi.other.api.domain.TVip; |
| | | import com.ruoyi.other.api.dto.AdvertisingDTO; |
| | |
| | | |
| | | |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.common.log.annotation.Log; |
| | | import com.ruoyi.common.log.enums.BusinessType; |
| | | import com.ruoyi.other.api.domain.TEnterpriseUserApplication; |
| | | import com.ruoyi.other.service.TEnterpriseUserApplicationService; |
| | | import com.sun.xml.internal.bind.v2.TODO; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | /** |
| | |
| | | /** |
| | | * 添加计费策略管理 |
| | | */ |
| | | @ApiOperation(tags = {"小程序-计费策略","后台-申请表单-集团用户"},value = "添加集团用户申请") |
| | | @Log(title = "添加集团用户申请", businessType = BusinessType.INSERT) |
| | | @ApiOperation(tags = {"小程序-计费策略"},value = "添加集团用户申请") |
| | | @PostMapping(value = "/add") |
| | | public AjaxResult<Boolean> add(@RequestBody TEnterpriseUserApplication dto) { |
| | | public AjaxResult<Boolean> add(@Validated @RequestBody TEnterpriseUserApplication dto) { |
| | | // TODO 用户id |
| | | return AjaxResult.ok(enterpriseUserApplicationService.save(dto)); |
| | | } |
| | |
| | | package com.ruoyi.other.controller; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.other.api.domain.TRoleSite; |
| | | import com.ruoyi.other.service.TRoleSiteService; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @RequestMapping("/t-role-site") |
| | | public class TRoleSiteController { |
| | | |
| | | @Resource |
| | | private TRoleSiteService roleSiteService; |
| | | |
| | | |
| | | @ResponseBody |
| | | @GetMapping("/getSiteIds") |
| | | public R<List<Integer>> getSiteIds(@RequestParam("roleId") Long roleId){ |
| | | List<TRoleSite> list = roleSiteService.list(new LambdaQueryWrapper<TRoleSite>().eq(TRoleSite::getRoleId, roleId)); |
| | | List<Integer> collect = list.stream().map(TRoleSite::getSiteId).collect(Collectors.toList()); |
| | | return R.ok(collect); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | |
| | | import com.ruoyi.other.api.domain.TSystemConfiguration; |
| | | import com.ruoyi.other.service.TSystemConfigurationService; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | |
| | | */ |
| | | @ApiOperation(tags = {"小程序-系统设置"},value = "联系客服") |
| | | @GetMapping(value = "/getDetailById") |
| | | public AjaxResult<TSystemConfiguration> getDetailById(@RequestParam(name = "type",value = "1=客服信息,2=系统设置") Integer type) { |
| | | public AjaxResult<TSystemConfiguration> getDetailById(@RequestParam(name = "type")@ApiParam(value = "1=客服信息,2=系统设置") Integer type) { |
| | | return AjaxResult.ok(systemConfigurationService.getOne(Wrappers.lambdaQuery(TSystemConfiguration.class) |
| | | .eq(TSystemConfiguration::getType, type))); |
| | | } |
| | |
| | | package com.ruoyi.other.controller; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.other.api.domain.TUserSite; |
| | | import com.ruoyi.other.service.TUserSiteService; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @RequestMapping("/t-user-site") |
| | | public class TUserSiteController { |
| | | |
| | | @Resource |
| | | private TUserSiteService userSiteService; |
| | | |
| | | |
| | | /** |
| | | * 根据用户id获取可访问的站点数据 |
| | | * @param userId 用户id |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @GetMapping("/getSiteIds") |
| | | public R<List<Integer>> getSiteIds(@RequestParam("userId") Long userId){ |
| | | List<TUserSite> list = userSiteService.list(new LambdaQueryWrapper<TUserSite>().eq(TUserSite::getUserId, userId)); |
| | | List<Integer> collect = list.stream().map(TUserSite::getSiteId).collect(Collectors.toList()); |
| | | return R.ok(collect); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | |
| | | name: ruoyi-other |
| | | main: |
| | | allow-bean-definition-overriding: true |
| | | allow-circular-references: true |
| | | profiles: |
| | | # 环境配置 |
| | | active: dev |
| | |
| | | name: ruoyi-payment |
| | | main: |
| | | allow-bean-definition-overriding: true |
| | | allow-circular-references: true |
| | | profiles: |
| | | # 环境配置 |
| | | active: dev |