站控新增锁定调整
This commit is contained in:
parent
46e44eeed0
commit
24f0b6607f
@ -10,6 +10,7 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -143,4 +144,11 @@ public class BatteryStation extends BaseEntity implements Serializable {
|
||||
|
||||
@Schema(description = "告警状态", hidden = true)
|
||||
private Boolean alarm;
|
||||
|
||||
@Schema(description = "站端是否关闭运行")
|
||||
private Boolean stop;
|
||||
@Schema(description = "关停时间")
|
||||
private Date stopTime;
|
||||
@Schema(description = "锁定提醒")
|
||||
private String stopTip;
|
||||
}
|
||||
|
||||
@ -17,8 +17,10 @@ import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import org.springdoc.core.annotations.ParameterObject;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -62,6 +64,16 @@ public class BatteryStationController {
|
||||
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 = "站点秘钥")
|
||||
@PostMapping("/rsa_secret_key")
|
||||
|
||||
@ -17,7 +17,7 @@ import java.util.List;
|
||||
*/
|
||||
//换电站
|
||||
@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> {
|
||||
|
||||
|
||||
@ -33,6 +33,7 @@ public enum RequestFunctionTypesEnum {
|
||||
FUN_STARTSWAP("BatterySwapReq", "BatterySwapResponse", "站端回复开始换电"),
|
||||
FUN_STRATEGY_INFO("strategyInfo", "strategyInfoResponse", "站端查询充电策略"),
|
||||
FUN_PUSH_CAR_INFO("pushCarInfo", "pushCarInfoResponse", "根据车牌号创建车辆信息和预约单并返回状态信息"),
|
||||
FUN_BATTERY_STATUS("batteryStatusReq", "batteryStatusResponse", "站端状态查询"),
|
||||
;
|
||||
|
||||
String function;
|
||||
|
||||
@ -46,7 +46,7 @@ public class MqttResponse<T> implements Serializable {
|
||||
return this;
|
||||
}
|
||||
|
||||
public MqttResponse<T> success(T dataBody){
|
||||
public MqttResponse<T> success(T data){
|
||||
this.code=SUCCESS;
|
||||
this.msg="成功";
|
||||
this.data=data;
|
||||
|
||||
@ -184,6 +184,12 @@ public class MessageUtilService {
|
||||
|
||||
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) {
|
||||
JSONObject aesJo = getAESKey(stationCode);
|
||||
|
||||
@ -1,14 +1,11 @@
|
||||
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.evotech.hd.cloud.mqtt.message.handle.MessageUtilService;
|
||||
import com.evotech.hd.cloud.open.processor.StrategyFactory;
|
||||
import com.evotech.hd.cloud.service.BatteryStationSecretKeyService;
|
||||
import com.evotech.hd.common.core.Dto.Result;
|
||||
import com.evotech.hd.common.core.constant.HDConstant;
|
||||
import com.evotech.hd.common.core.utils.Collections;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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.RestController;
|
||||
|
||||
import java.util.Base64;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 类
|
||||
*
|
||||
@ -36,17 +30,27 @@ public class OpenStationController {
|
||||
BatteryStationSecretKeyService batteryStationSecretKeyService;
|
||||
@Autowired
|
||||
private StrategyFactory strategyFactory;
|
||||
@Resource
|
||||
private MessageUtilService messageUtilService;
|
||||
|
||||
@PostMapping("/message")
|
||||
public Result message(@Valid @RequestBody OpenParams params){
|
||||
Map<String, String> secretKeyMap = batteryStationSecretKeyService.getStationSecretKeyByStationCode(params.getStationCode());
|
||||
if(Collections.isEmpty(secretKeyMap)){
|
||||
return Result.getInstance().error("未找到当前站端的秘钥信息");
|
||||
|
||||
cn.hutool.json.JSONObject jo = new cn.hutool.json.JSONObject();
|
||||
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));
|
||||
if(!verifier.verify(params.getData().getBytes(), Base64.getDecoder().decode(params.getSign()))){
|
||||
return Result.getInstance().error("当前信息已被篡改");
|
||||
}
|
||||
return strategyFactory.exchange(JSONObject.parseObject(params.getData()));
|
||||
// Map<String, String> secretKeyMap = batteryStationSecretKeyService.getStationSecretKeyByStationCode(params.getStationCode());
|
||||
// if(Collections.isEmpty(secretKeyMap)){
|
||||
// return Result.getInstance().error("未找到当前站端的秘钥信息");
|
||||
// }
|
||||
// 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()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ import com.evotech.hd.common.core.entity.cloud.BatteryStation;
|
||||
import com.evotech.hd.common.core.entity.cloud.vo.BatteryStationVO;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -16,6 +17,8 @@ public interface BatteryStationService {
|
||||
|
||||
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<Page<BatteryStation>> list(PageListBatteryStationRequest plbsr);
|
||||
|
||||
@ -25,7 +25,7 @@ public class BatteryStationSecretKeyServiceImpl implements BatteryStationSecretK
|
||||
public Map<String, String> getStationSecretKeyByStationCode(String stationCode) {
|
||||
BatteryStationSecretKey existingKey = batteryStationSecretKeyDao.selectOne(
|
||||
new QueryWrapper<BatteryStationSecretKey>()
|
||||
.eq("type", 1)
|
||||
.eq("type", 2)
|
||||
.eq("station_code", stationCode),
|
||||
false
|
||||
);
|
||||
|
||||
@ -145,6 +145,23 @@ public class BatteryStationServiceImpl implements BatteryStationService {
|
||||
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
|
||||
public Result<Integer> update(BatteryStation bs) {
|
||||
int n = batteryStationDao.updateById(bs);
|
||||
|
||||
@ -175,6 +175,7 @@ public class OrderSwapBatteryPreServiceImpl extends ServiceImpl<OrderSwapBattery
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Result<Page<OrderSwapBatteryPre>> list(PageListSwapOrderPreRequest plsopr) {
|
||||
Page<OrderSwapBatteryPre> page = new Page<OrderSwapBatteryPre>(plsopr.getPageNo(), plsopr.getPageSize());
|
||||
|
||||
@ -55,7 +55,7 @@
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<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>
|
||||
|
||||
|
||||
|
||||
@ -203,6 +203,7 @@ public class AuthorizationManager implements ReactiveAuthorizationManager<Author
|
||||
}
|
||||
//验证正则匹配是否通过
|
||||
if(notPermission){
|
||||
System.out.println(path);
|
||||
throw new OAuth2AuthorizationException(new OAuth2Error(CodeMsg.ACCESS_DENY.getCode(), CodeMsg.ACCESS_DENY.getMsg(), uri));
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user