站控新增锁定调整

This commit is contained in:
andy 2026-06-25 11:26:54 +08:00
parent 46e44eeed0
commit 24f0b6607f
13 changed files with 76 additions and 23 deletions

View File

@ -10,6 +10,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
@ -143,4 +144,11 @@ public class BatteryStation extends BaseEntity implements Serializable {
@Schema(description = "告警状态", hidden = true) @Schema(description = "告警状态", hidden = true)
private Boolean alarm; private Boolean alarm;
@Schema(description = "站端是否关闭运行")
private Boolean stop;
@Schema(description = "关停时间")
private Date stopTime;
@Schema(description = "锁定提醒")
private String stopTip;
} }

View File

@ -17,8 +17,10 @@ import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotBlank;
import org.springdoc.core.annotations.ParameterObject; import org.springdoc.core.annotations.ParameterObject;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -62,6 +64,16 @@ public class BatteryStationController {
return batteryStationService.list(plbsr); return batteryStationService.list(plbsr);
} }
@Operation(summary = "站点关停")
@PutMapping("/stop/{id}")
@ApiOperationSupport(order = 2)
public Result<Integer> stop(@PathVariable("id") Integer id,
@RequestParam(name = "stop") Boolean stop,
@RequestParam(name = "stopTime",required = false) Date stopTime,
@RequestParam(name = "stopTip",required = false) String stopTip) {
return batteryStationService.stop(id, stop, stopTime, stopTip);
}
@Operation(summary = "站点秘钥") @Operation(summary = "站点秘钥")
@PostMapping("/rsa_secret_key") @PostMapping("/rsa_secret_key")

View File

@ -17,7 +17,7 @@ import java.util.List;
*/ */
//换电站 //换电站
@DataScopes({ @DataScopes({
@DataScope(permissionObject = HDConstant.OPERATOR_ROLE_CODE, permissionScopeName = "pk_id", permissionScopeRedisKey = HDConstant.PermissionConstant.PERMISSION_STATION_ID) @DataScope(permissionObject = HDConstant.OPERATOR_ROLE_CODE, permissionScopeName = "proxy_Id", permissionScopeRedisKey = HDConstant.PermissionConstant.PERMISSION_STATION_ID)
}) })
public interface BatteryStationDao extends BaseMapper<BatteryStation> { public interface BatteryStationDao extends BaseMapper<BatteryStation> {

View File

@ -33,6 +33,7 @@ public enum RequestFunctionTypesEnum {
FUN_STARTSWAP("BatterySwapReq", "BatterySwapResponse", "站端回复开始换电"), FUN_STARTSWAP("BatterySwapReq", "BatterySwapResponse", "站端回复开始换电"),
FUN_STRATEGY_INFO("strategyInfo", "strategyInfoResponse", "站端查询充电策略"), FUN_STRATEGY_INFO("strategyInfo", "strategyInfoResponse", "站端查询充电策略"),
FUN_PUSH_CAR_INFO("pushCarInfo", "pushCarInfoResponse", "根据车牌号创建车辆信息和预约单并返回状态信息"), FUN_PUSH_CAR_INFO("pushCarInfo", "pushCarInfoResponse", "根据车牌号创建车辆信息和预约单并返回状态信息"),
FUN_BATTERY_STATUS("batteryStatusReq", "batteryStatusResponse", "站端状态查询"),
; ;
String function; String function;

View File

@ -46,7 +46,7 @@ public class MqttResponse<T> implements Serializable {
return this; return this;
} }
public MqttResponse<T> success(T dataBody){ public MqttResponse<T> success(T data){
this.code=SUCCESS; this.code=SUCCESS;
this.msg="成功"; this.msg="成功";
this.data=data; this.data=data;

View File

@ -184,6 +184,12 @@ public class MessageUtilService {
return JSONUtil.parseObj(decrypt); return JSONUtil.parseObj(decrypt);
} }
public JSONObject decryptAesMessage(String stationCode, String message) {
SymmetricCrypto aes = getAes(stationCode);
String decrypt = aes.decryptStr(new String(message));
return JSONUtil.parseObj(decrypt);
}
public SymmetricCrypto getAes(String stationCode) { public SymmetricCrypto getAes(String stationCode) {
JSONObject aesJo = getAESKey(stationCode); JSONObject aesJo = getAESKey(stationCode);

View File

@ -1,14 +1,11 @@
package com.evotech.hd.cloud.open; package com.evotech.hd.cloud.open;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.asymmetric.Sign;
import cn.hutool.crypto.asymmetric.SignAlgorithm;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.evotech.hd.cloud.mqtt.message.handle.MessageUtilService;
import com.evotech.hd.cloud.open.processor.StrategyFactory; import com.evotech.hd.cloud.open.processor.StrategyFactory;
import com.evotech.hd.cloud.service.BatteryStationSecretKeyService; import com.evotech.hd.cloud.service.BatteryStationSecretKeyService;
import com.evotech.hd.common.core.Dto.Result; import com.evotech.hd.common.core.Dto.Result;
import com.evotech.hd.common.core.constant.HDConstant; import jakarta.annotation.Resource;
import com.evotech.hd.common.core.utils.Collections;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -17,9 +14,6 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.Base64;
import java.util.Map;
/** /**
* *
* *
@ -36,17 +30,27 @@ public class OpenStationController {
BatteryStationSecretKeyService batteryStationSecretKeyService; BatteryStationSecretKeyService batteryStationSecretKeyService;
@Autowired @Autowired
private StrategyFactory strategyFactory; private StrategyFactory strategyFactory;
@Resource
private MessageUtilService messageUtilService;
@PostMapping("/message") @PostMapping("/message")
public Result message(@Valid @RequestBody OpenParams params){ public Result message(@Valid @RequestBody OpenParams params){
Map<String, String> secretKeyMap = batteryStationSecretKeyService.getStationSecretKeyByStationCode(params.getStationCode());
if(Collections.isEmpty(secretKeyMap)){ cn.hutool.json.JSONObject jo = new cn.hutool.json.JSONObject();
return Result.getInstance().error("未找到当前站端的秘钥信息"); try {
jo = messageUtilService.decryptAesMessage(params.getStationCode(), params.getData());
} catch (Exception e) {
e.printStackTrace();
return Result.getInstance().error("推送信息解密失败");
} }
Sign verifier = SecureUtil.sign(SignAlgorithm.SHA256withRSA, null, secretKeyMap.get(HDConstant.PUBLIC_KEY)); // Map<String, String> secretKeyMap = batteryStationSecretKeyService.getStationSecretKeyByStationCode(params.getStationCode());
if(!verifier.verify(params.getData().getBytes(), Base64.getDecoder().decode(params.getSign()))){ // if(Collections.isEmpty(secretKeyMap)){
return Result.getInstance().error("当前信息已被篡改"); // return Result.getInstance().error("未找到当前站端的秘钥信息");
} // }
return strategyFactory.exchange(JSONObject.parseObject(params.getData())); // Sign verifier = SecureUtil.sign(SignAlgorithm.SHA256withRSA, null, secretKeyMap.get(HDConstant.PUBLIC_KEY));
// if(!verifier.verify(params.getData().getBytes(), Base64.getDecoder().decode(params.getSign()))){
// return Result.getInstance().error("当前信息已被篡改");
// }
return strategyFactory.exchange(JSONObject.parseObject(jo.toString()));
} }
} }

View File

@ -7,6 +7,7 @@ import com.evotech.hd.common.core.entity.cloud.BatteryStation;
import com.evotech.hd.common.core.entity.cloud.vo.BatteryStationVO; import com.evotech.hd.common.core.entity.cloud.vo.BatteryStationVO;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -16,6 +17,8 @@ public interface BatteryStationService {
public Result<Integer> delete(Integer id); public Result<Integer> delete(Integer id);
public Result<Integer> stop(Integer id, Boolean stop, Date stopTime, String stopTip);
public Result<Integer> update(BatteryStation bs); public Result<Integer> update(BatteryStation bs);
public Result<Page<BatteryStation>> list(PageListBatteryStationRequest plbsr); public Result<Page<BatteryStation>> list(PageListBatteryStationRequest plbsr);

View File

@ -25,7 +25,7 @@ public class BatteryStationSecretKeyServiceImpl implements BatteryStationSecretK
public Map<String, String> getStationSecretKeyByStationCode(String stationCode) { public Map<String, String> getStationSecretKeyByStationCode(String stationCode) {
BatteryStationSecretKey existingKey = batteryStationSecretKeyDao.selectOne( BatteryStationSecretKey existingKey = batteryStationSecretKeyDao.selectOne(
new QueryWrapper<BatteryStationSecretKey>() new QueryWrapper<BatteryStationSecretKey>()
.eq("type", 1) .eq("type", 2)
.eq("station_code", stationCode), .eq("station_code", stationCode),
false false
); );

View File

@ -145,6 +145,23 @@ public class BatteryStationServiceImpl implements BatteryStationService {
throw new RuntimeException("删除换电站出错!"); throw new RuntimeException("删除换电站出错!");
} }
@Override
public Result<Integer> stop(Integer id, Boolean stop, Date stopTime, String stopTip) {
BatteryStation bs = new BatteryStation();
bs.setPkId(id);
bs.setStop(stop);
// true为锁定
if(stop){
bs.setStopTime(stopTime);
bs.setStopTip(stopTip);
}
int n = batteryStationDao.updateById(bs);
if (n == 1) {
return new Result<Integer>().success(n);
}
throw new RuntimeException("换电站关停出错!");
}
@Override @Override
public Result<Integer> update(BatteryStation bs) { public Result<Integer> update(BatteryStation bs) {
int n = batteryStationDao.updateById(bs); int n = batteryStationDao.updateById(bs);

View File

@ -175,6 +175,7 @@ public class OrderSwapBatteryPreServiceImpl extends ServiceImpl<OrderSwapBattery
} }
@Override @Override
public Result<Page<OrderSwapBatteryPre>> list(PageListSwapOrderPreRequest plsopr) { public Result<Page<OrderSwapBatteryPre>> list(PageListSwapOrderPreRequest plsopr) {
Page<OrderSwapBatteryPre> page = new Page<OrderSwapBatteryPre>(plsopr.getPageNo(), plsopr.getPageSize()); Page<OrderSwapBatteryPre> page = new Page<OrderSwapBatteryPre>(plsopr.getPageNo(), plsopr.getPageSize());

View File

@ -55,7 +55,7 @@
<!-- 通用查询结果列 --> <!-- 通用查询结果列 -->
<sql id="Base_Column_List"> <sql id="Base_Column_List">
pk_id, proxy_id, name, code, status, type, address, address_province, address_city, address_area, register_date, contacts, phone, del_flag, active_date, location_point, open_all_day, td_quantity, jqr_quantity, cdj_quantity, dcc_quantity, dc_quantity, ctime, creater, uptime, updater, division_no pk_id, proxy_id, name, code, status, type, address, address_province, address_city, address_area, register_date, contacts, phone, del_flag, active_date, location_point, open_all_day, td_quantity, jqr_quantity, cdj_quantity, dcc_quantity, dc_quantity, ctime, creater, uptime, updater, division_no, stop, stop_time, stop_tip
</sql> </sql>

View File

@ -203,6 +203,7 @@ public class AuthorizationManager implements ReactiveAuthorizationManager<Author
} }
//验证正则匹配是否通过 //验证正则匹配是否通过
if(notPermission){ if(notPermission){
System.out.println(path);
throw new OAuth2AuthorizationException(new OAuth2Error(CodeMsg.ACCESS_DENY.getCode(), CodeMsg.ACCESS_DENY.getMsg(), uri)); throw new OAuth2AuthorizationException(new OAuth2Error(CodeMsg.ACCESS_DENY.getCode(), CodeMsg.ACCESS_DENY.getMsg(), uri));
} }
} }