1. 调整公司接口
2. 添加公司员工绑定接口 3. 添加公司车辆关联接口 4. 修复mybatis分页查询无总数bug 5. 完善换电站费用标准 6. 完善换电交互逻辑 7. 修改token过期时的返回bug
This commit is contained in:
parent
08ef590c4f
commit
f2921afcc8
@ -48,8 +48,8 @@ public class LoginController {
|
||||
|
||||
@Operation(summary = "检验token")
|
||||
@PostMapping("/checktoken")
|
||||
public Result<Boolean> checkToken(String token) throws AuthenticationException {
|
||||
return loginService.checkToken(token);
|
||||
public Result<Boolean> checkToken() {
|
||||
return loginService.checkToken();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -13,5 +13,5 @@ public interface LoginService {
|
||||
|
||||
public Result<String> logout(HttpServletRequest request);
|
||||
|
||||
public Result<Boolean> checkToken(String token) throws AuthenticationException;
|
||||
public Result<Boolean> checkToken();
|
||||
}
|
||||
|
||||
@ -190,10 +190,7 @@ public class LoginServiceImpl implements LoginService {
|
||||
|
||||
|
||||
@Override
|
||||
public Result<Boolean> checkToken(String token) throws AuthenticationException {
|
||||
// TODO 发送到自带的token验证接口 验证
|
||||
|
||||
|
||||
public Result<Boolean> checkToken() {
|
||||
return new Result<Boolean>().success(true);
|
||||
}
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@ public class Oauth2AccessTokenUtil {
|
||||
tokenRes.setTokenType(jo1.getStr("token_type"));
|
||||
return tokenRes;
|
||||
} else {
|
||||
throw new RuntimeException("生成token出错");
|
||||
throw new RuntimeException("生成登陆令牌异常!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -51,17 +51,18 @@ public class BatteryStationDc implements Serializable {
|
||||
@NotNull(message = "初始来源不能为空")
|
||||
private Integer sourceFrom;
|
||||
|
||||
@Schema(description = "站码或车牌照")
|
||||
@Schema(description = "站码或车牌照", requiredMode = RequiredMode.REQUIRED)
|
||||
@NotBlank
|
||||
private String sourceCode;
|
||||
|
||||
@Schema(description = "状态:1-出租中,2-充电中,3-充电完毕,4-故障,5-其它", requiredMode = RequiredMode.REQUIRED)
|
||||
@Schema(description = "状态:1-出租中,2-充电中,3-空闲,4-故障,5-其它", requiredMode = RequiredMode.REQUIRED)
|
||||
@NotNull(message = "状态不能为空")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "换电站编码")
|
||||
private String stationCode;
|
||||
|
||||
@Schema(description = "换电站编码")
|
||||
@Schema(description = "换电站名称")
|
||||
private String stationName;
|
||||
|
||||
@Schema(description = "当前电量")
|
||||
|
||||
@ -54,6 +54,15 @@ public class BatteryStationHdFeeStandard implements Serializable {
|
||||
@Schema(description = "结束日期", requiredMode = RequiredMode.REQUIRED, example = DatePattern.PURE_DATE_PATTERN)
|
||||
@NotBlank(message = "结束时间不能为空")
|
||||
private String dayEnd;
|
||||
|
||||
@Schema(description = "每公里收费")
|
||||
private BigDecimal eachKmFee;
|
||||
|
||||
@Schema(description = "每SOC收费")
|
||||
private BigDecimal eachSocFee;
|
||||
|
||||
@Schema(description = "每度电收费")
|
||||
private BigDecimal eachKwhFee;
|
||||
|
||||
@Schema(description = "正常换电服务费")
|
||||
private BigDecimal commonRemainFee;
|
||||
|
||||
@ -81,7 +81,7 @@ public class OrderSwapBattery implements Serializable {
|
||||
private Integer feeType;
|
||||
|
||||
@Schema(description = "基础费用")
|
||||
private Integer basicFee;
|
||||
private BigDecimal basicFee;
|
||||
|
||||
@Schema(description = "服务开始时间")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ -94,7 +94,7 @@ public class OrderSwapBattery implements Serializable {
|
||||
private Date serviceTimeEnd;
|
||||
|
||||
@Schema(description = "服务费")
|
||||
private Integer serviceFee;
|
||||
private BigDecimal serviceFee;
|
||||
|
||||
@Schema(description = "上次租赁电池时车辆里程")
|
||||
private BigDecimal lastRentBatCarOdo;
|
||||
|
||||
@ -48,6 +48,9 @@ public class PageListSwapOrderRequest extends BasePageRequest {
|
||||
|
||||
@Schema(description = "交易编码")
|
||||
private String tradeNo;
|
||||
|
||||
@Schema(description = "订单状态:1-已创建,2-换电中,3-换电完成,4-充电中,5-充电完成,6-待结算,7-已完成,9-已取消")
|
||||
private String status;
|
||||
|
||||
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@ import jakarta.validation.constraints.NotBlank;
|
||||
|
||||
|
||||
@Tag(name = "车辆管理")
|
||||
@ApiSupport(order = 21)
|
||||
@ApiSupport(order = 31)
|
||||
@RestController
|
||||
@RequestMapping("/vehicle")
|
||||
public class VehicleController {
|
||||
@ -64,9 +64,16 @@ public class VehicleController {
|
||||
return vehicleService.list(plvr);
|
||||
}
|
||||
|
||||
@Operation(summary = "公司关联")
|
||||
@PostMapping("/company/relation")
|
||||
@ApiOperationSupport(order = 5)
|
||||
public Result<Integer> companyRelation(String plateNum, String ccode, String cname) {
|
||||
return vehicleService.companyRelation(plateNum, ccode, cname);
|
||||
}
|
||||
|
||||
@Operation(summary = "微信用户关联")
|
||||
@PostMapping("/wechatuser/relation/add")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@ApiOperationSupport(order = 6)
|
||||
public Result<Integer> addWechatUserRelation(@Valid @ParameterObject VehicleWechatUserRelation relation) {
|
||||
return vehicleService.addWechatUserRelation(relation);
|
||||
}
|
||||
@ -74,7 +81,7 @@ public class VehicleController {
|
||||
|
||||
@Operation(summary = "删除微信用户关联")
|
||||
@PostMapping("/wechatuser/relation/del")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@ApiOperationSupport(order = 7)
|
||||
public Result<Integer> deleteWechatUserRelation(Integer id) {
|
||||
return vehicleService.deleteWechatUserRelation(id);
|
||||
}
|
||||
@ -82,9 +89,12 @@ public class VehicleController {
|
||||
|
||||
@Operation(summary = "查询微信用户车辆")
|
||||
@GetMapping("/wechatuser/relation/list")
|
||||
@ApiOperationSupport(order = 7)
|
||||
public Result<List<VehicleInfo>> listWechatUserRelation(@NotBlank @RequestParam String openid) {
|
||||
return vehicleService.listWechatUserRelation(openid, null);
|
||||
@ApiOperationSupport(order = 8)
|
||||
public Result<List<VehicleInfo>> listWechatUserRelation(@NotBlank @RequestParam String wuid) {
|
||||
return vehicleService.listWechatUserRelation(wuid, null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import org.springdoc.core.annotations.ParameterObject;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.evotech.hd.cloud.service.OrderSwapBatteryService;
|
||||
@ -91,5 +92,12 @@ public class OrderSwapBatteryController {
|
||||
public Result<List<OrderSwapBatteryStep>> listStep(@NotBlank String orderNo) {
|
||||
return orderSwapBatteryService.listStep(orderNo);
|
||||
}
|
||||
|
||||
@Operation(summary = "费用计算")
|
||||
@PostMapping({"/cost"})
|
||||
@ApiOperationSupport(order = 9)
|
||||
public Result<String> calculateCost(@NotBlank @RequestParam String orderNo) {
|
||||
return orderSwapBatteryService.calculateCost(orderNo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,6 +2,8 @@ package com.evotech.hd.cloud.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.evotech.hd.common.core.entity.cloud.BatteryStationHdFeeStandard;
|
||||
|
||||
@ -11,6 +13,6 @@ import com.evotech.hd.common.core.entity.cloud.BatteryStationHdFeeStandard;
|
||||
*/
|
||||
public interface BatteryStationHdFeeStandardDao extends BaseMapper<BatteryStationHdFeeStandard> {
|
||||
|
||||
List<BatteryStationHdFeeStandard> listFeeStandard(String stationCode);
|
||||
List<BatteryStationHdFeeStandard> listFeeStandard(@Param("stationCode") String stationCode, @Param("day") String day);
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.evotech.hd.cloud.mqtt.message.handle;
|
||||
|
||||
import java.time.LocalTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@ -12,6 +13,7 @@ import org.springframework.util.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.evotech.hd.cloud.dao.BatteryStationDcDao;
|
||||
import com.evotech.hd.cloud.dao.BatteryStationHdFeeStandardDao;
|
||||
import com.evotech.hd.cloud.dao.OrderSwapBatteryDao;
|
||||
import com.evotech.hd.cloud.dao.OrderSwapBatteryPreDao;
|
||||
import com.evotech.hd.cloud.dao.VehicleWechatUserRelationDao;
|
||||
@ -29,10 +31,11 @@ import com.evotech.hd.cloud.mqtt.message.dto.newer.req.order.OrderData;
|
||||
import com.evotech.hd.cloud.service.OrderSwapBatteryService;
|
||||
import com.evotech.hd.cloud.utils.CommonUtil;
|
||||
import com.evotech.hd.common.core.entity.cloud.BatteryStationDc;
|
||||
import com.evotech.hd.common.core.entity.cloud.BatteryStationHdFeeStandard;
|
||||
import com.evotech.hd.common.core.entity.cloud.BatteryStationHdFeeStandardDetail;
|
||||
import com.evotech.hd.common.core.entity.cloud.OrderSwapBattery;
|
||||
import com.evotech.hd.common.core.entity.cloud.OrderSwapBatteryPre;
|
||||
import com.evotech.hd.common.core.entity.cloud.VehicleWechatUserRelation;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
@ -57,6 +60,8 @@ public class RequestMessageService {
|
||||
private OrderSwapBatteryPreDao orderSwapBatteryPreDao;
|
||||
@Resource
|
||||
private OrderSwapBatteryService orderSwapBatteryService;
|
||||
@Resource
|
||||
private BatteryStationHdFeeStandardDao batteryStationHdFeeStandardDao;
|
||||
|
||||
@Async("taskExecutor")
|
||||
public void request(MessageTopic topic, MqttMessageHeader header, JSONObject dataBody) {
|
||||
@ -102,6 +107,7 @@ public class RequestMessageService {
|
||||
OrderSwapBatteryPre osbp = orderSwapBatteryPreDao.selectOne(new QueryWrapper<OrderSwapBatteryPre>()
|
||||
.eq("plate_num", orderByPlateNumReq.getPlateNum())
|
||||
.eq("station_code", orderByPlateNumReq.getStationCode())
|
||||
.eq("status", 1)
|
||||
.last("limit 1"));
|
||||
if (osbp == null) {
|
||||
response.setOrderRequestId(orderByPlateNumReq.getOrderRequestId());
|
||||
@ -127,6 +133,28 @@ public class RequestMessageService {
|
||||
osb.setStatus(1);
|
||||
osb.setStationCode(osbp.getStationCode());
|
||||
osb.setStationName(osbp.getStationName());
|
||||
// 加上费用标准
|
||||
List<BatteryStationHdFeeStandard> list = batteryStationHdFeeStandardDao.listFeeStandard(osbp.getStationCode(), DateUtil.format(d, DatePattern.PURE_DATE_FORMATTER));
|
||||
if (!list.isEmpty()) {
|
||||
BatteryStationHdFeeStandard standard = list.get(0);
|
||||
List<BatteryStationHdFeeStandardDetail> detailList = standard.getDetailList();
|
||||
if (!detailList.isEmpty()) {
|
||||
detailList = detailList.stream().filter(i -> i.getTimeBegin().compareTo(LocalTime.now()) <= 0)
|
||||
.filter(i -> i.getTimeEnd().compareTo(LocalTime.now()) >= 0).toList();
|
||||
if (!detailList.isEmpty()) {
|
||||
BatteryStationHdFeeStandardDetail detail = detailList.get(0);
|
||||
osb.setBasicFee(detail.getEachKwhFee());
|
||||
osb.setServiceFee(detail.getTimeServiceFee());
|
||||
} else {
|
||||
osb.setBasicFee(standard.getEachKwhFee());
|
||||
osb.setServiceFee(standard.getCommonRemainFee());
|
||||
}
|
||||
} else {
|
||||
osb.setBasicFee(standard.getEachKwhFee());
|
||||
osb.setServiceFee(standard.getCommonRemainFee());
|
||||
}
|
||||
}
|
||||
|
||||
orderSwapBatteryService.add(osb);
|
||||
}
|
||||
// 返回数据
|
||||
|
||||
@ -119,6 +119,7 @@ public class StateMessageService {
|
||||
bt1.setBeginTime(orderStatus.getStatusTime());
|
||||
bt1.setPointType(2);
|
||||
bt1.setPointCode(osb.getPlateNum());
|
||||
bt1.setPointName(osb.getPlateNum());
|
||||
bt1.setCreater("SYS");
|
||||
BatteryTrace bt2 = new BatteryTrace();
|
||||
BeanUtils.copyProperties(bt1, bt2);
|
||||
|
||||
@ -25,5 +25,7 @@ public interface OrderSwapBatteryService {
|
||||
public Result<List<OrderSwapBattery>> list(PageListSwapOrderRequest plsor);
|
||||
|
||||
public Result<List<OrderSwapBatteryStep>> listStep(String orderNo);
|
||||
|
||||
public Result<String> calculateCost(String orderNo);
|
||||
|
||||
}
|
||||
|
||||
@ -17,6 +17,8 @@ public interface VehicleService {
|
||||
|
||||
public Result<List<VehicleInfo>> list(PageListVehicleRequest plvr);
|
||||
|
||||
public Result<Integer> companyRelation(String plateNum, String ccode, String cname);
|
||||
|
||||
public Result<Integer> addWechatUserRelation(VehicleWechatUserRelation relation);
|
||||
|
||||
public Result<Integer> deleteWechatUserRelation(Integer id);
|
||||
|
||||
@ -40,7 +40,7 @@ public class BatteryStationDcServiceImpl implements BatteryStationDcService {
|
||||
bt.setCreater("SYS");
|
||||
bt.setPointType(bsdc.getSourceFrom());
|
||||
bt.setPointCode(bt.getPointType() == 1? bsdc.getStationCode():bsdc.getSourceCode());
|
||||
bt.setPointName(bt.getPointType() == 1? bsdc.getStationName():"");
|
||||
bt.setPointName(bt.getPointType() == 1? bsdc.getStationName():bsdc.getSourceCode());
|
||||
addTrace(bt);
|
||||
return new Result<Integer>().success(n);
|
||||
}
|
||||
|
||||
@ -22,6 +22,14 @@ public class BatteryStationHdFeeStandardDetailServiceImpl implements BatteryStat
|
||||
|
||||
@Override
|
||||
public Result<Integer> add(BatteryStationHdFeeStandardDetail bsfsd) {
|
||||
boolean b = batteryStationHdFeeStandardDetailDao.exists(new QueryWrapper<BatteryStationHdFeeStandardDetail>()
|
||||
.or(i -> i.and(j -> j.le("time_begin", bsfsd.getTimeBegin()).ge("time_end", bsfsd.getTimeBegin()))
|
||||
.or(j -> j.le("time_begin", bsfsd.getTimeEnd()).ge("time_end", bsfsd.getTimeEnd()))
|
||||
.or(j -> j.ge("day_begin", bsfsd.getTimeBegin()).le("day_end", bsfsd.getTimeEnd())))
|
||||
.eq("standard_id", bsfsd.getStandardId()));
|
||||
if (b) {
|
||||
return new Result<Integer>().error("换电站费用标准明细时间冲突!");
|
||||
}
|
||||
bsfsd.setCtime(new Date());
|
||||
int n = batteryStationHdFeeStandardDetailDao.insert(bsfsd);
|
||||
if (n == 1) {
|
||||
|
||||
@ -27,6 +27,15 @@ public class BatteryStationHdFeeStandardServiceImpl implements BatteryStationHdF
|
||||
|
||||
@Override
|
||||
public Result<Integer> add(BatteryStationHdFeeStandard bsfs) {
|
||||
boolean b = batteryStationHdFeeStandardDao.exists(new QueryWrapper<BatteryStationHdFeeStandard>()
|
||||
.or(i -> i.and(j -> j.le("day_begin", bsfs.getDayBegin()).ge("day_end", bsfs.getDayBegin()))
|
||||
.or(j -> j.le("day_begin", bsfs.getDayEnd()).ge("day_end", bsfs.getDayEnd()))
|
||||
.or(j -> j.ge("day_begin", bsfs.getDayBegin()).le("day_end", bsfs.getDayEnd())))
|
||||
.eq("station_code", bsfs.getStationCode()));
|
||||
if (b) {
|
||||
return new Result<Integer>().error("换电站费用标准日期冲突!");
|
||||
}
|
||||
|
||||
bsfs.setCtime(new Date());
|
||||
int n = batteryStationHdFeeStandardDao.insert(bsfs);
|
||||
if (n == 1) {
|
||||
@ -57,7 +66,7 @@ public class BatteryStationHdFeeStandardServiceImpl implements BatteryStationHdF
|
||||
|
||||
@Override
|
||||
public Result<List<BatteryStationHdFeeStandard>> list(String stationCode) {
|
||||
List<BatteryStationHdFeeStandard> list = batteryStationHdFeeStandardDao.listFeeStandard(stationCode);
|
||||
List<BatteryStationHdFeeStandard> list = batteryStationHdFeeStandardDao.listFeeStandard(stationCode, null);
|
||||
if (list.isEmpty()) {
|
||||
return new Result<List<BatteryStationHdFeeStandard>>().error(CodeMsg.DATABASE_RESULT_NULL);
|
||||
}
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
package com.evotech.hd.cloud.service.impl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@ -135,18 +138,29 @@ public class OrderSwapBatteryServiceImpl implements OrderSwapBatteryService {
|
||||
public Result<List<OrderSwapBattery>> list(PageListSwapOrderRequest plsor) {
|
||||
Page<OrderSwapBattery> page = new Page<OrderSwapBattery>(plsor.getPageNo(), plsor.getPageSize());
|
||||
|
||||
List<String> plateNumList = new ArrayList<String>();
|
||||
if (StringUtils.hasText(plsor.getPlateNums())) {
|
||||
plateNumList = Arrays.asList(plsor.getPlateNums().split(","));
|
||||
}
|
||||
List<Integer> statusList = new ArrayList<Integer>();
|
||||
if (StringUtils.hasText(plsor.getStatus())) {
|
||||
statusList = Arrays.asList(plsor.getStatus().split(",")).stream().map(i -> Integer.valueOf(i)).toList();
|
||||
}
|
||||
|
||||
page = orderSwapBatteryDao.selectPage(page, new QueryWrapper<OrderSwapBattery>()
|
||||
.eq(StringUtils.hasText(plsor.getOrderNo()), "order_no", plsor.getOrderNo())
|
||||
.eq(StringUtils.hasText(plsor.getPlateNum()), "plate_num", plsor.getPlateNum())
|
||||
.in(StringUtils.hasText(plsor.getPlateNums()), "plate_num", Arrays.asList(plsor.getPlateNums().split(",")))
|
||||
.in(!plateNumList.isEmpty(), "plate_num", plateNumList)
|
||||
.in(!statusList.isEmpty(), "status", statusList)
|
||||
.ge(plsor.getOrderTimeBegin() != null, "order_time", plsor.getOrderTimeBegin())
|
||||
.le(plsor.getOrderTimeEnd() != null, "order_time", plsor.getOrderTimeEnd())
|
||||
.eq(StringUtils.hasText(plsor.getStationCode()), "station_code", plsor.getStationCode())
|
||||
.like(StringUtils.hasText(plsor.getStationName()), "station_name", plsor.getStationName())
|
||||
.eq(StringUtils.hasText(plsor.getUserId()), "user_id", plsor.getUserId())
|
||||
.eq(StringUtils.hasText(plsor.getUserId()), "order_pre_uid", plsor.getUserId())
|
||||
.eq(StringUtils.hasText(plsor.getTradeNo()), "trade_no", plsor.getTradeNo())
|
||||
.ne("del_flag", 1)
|
||||
.orderByDesc("pk_id"));
|
||||
System.out.println(page.getTotal());
|
||||
if (page.getRecords().isEmpty()) {
|
||||
return new Result<List<OrderSwapBattery>>().error(CodeMsg.DATABASE_RESULT_NULL);
|
||||
}
|
||||
@ -163,4 +177,31 @@ public class OrderSwapBatteryServiceImpl implements OrderSwapBatteryService {
|
||||
return new Result<List<OrderSwapBatteryStep>>().success(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<String> calculateCost(String orderNo) {
|
||||
OrderSwapBattery order = orderSwapBatteryDao.selectOne(new QueryWrapper<OrderSwapBattery>().eq("order_no", orderNo));
|
||||
if (order == null) {
|
||||
return new Result<String>().error("无此订单!");
|
||||
}
|
||||
// 1. 检查状态
|
||||
if (order.getStatus() != 5) {
|
||||
return new Result<String>().error("订单状态异常!");
|
||||
}
|
||||
// 2. 检查数据
|
||||
if (order.getBasicFee() == null || order.getServiceFee() == null) {
|
||||
return new Result<String>().error("订单费用标准异常!");
|
||||
}
|
||||
// 3. 选择费用计算方式 计算费用
|
||||
// 先按电量计算
|
||||
if (order.getElectAmount() == null) {
|
||||
return new Result<String>().error("充电订单 充电量 异常!");
|
||||
}
|
||||
BigDecimal fee = order.getServiceFee().add(order.getBasicFee().multiply(order.getElectAmount())).setScale(0, RoundingMode.HALF_UP);
|
||||
// 4. 修改订单
|
||||
order.setAmount(fee.intValue());
|
||||
order.setStatus(6);
|
||||
orderSwapBatteryDao.updateById(order);
|
||||
return new Result<String>().success(fee);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -78,6 +78,18 @@ public class VehicleServiceImpl implements VehicleService {
|
||||
}
|
||||
return new Result<List<VehicleInfo>>().success(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Integer> companyRelation(String plateNum, String ccode, String cname) {
|
||||
VehicleInfo vi = new VehicleInfo();
|
||||
vi.setCcode(ccode);
|
||||
vi.setCname(cname);
|
||||
int n = vehicleInfoDao.update(vi, new QueryWrapper<VehicleInfo>().eq("plate_num", plateNum));
|
||||
if (n == 1) {
|
||||
return new Result<Integer>().success(n);
|
||||
}
|
||||
return new Result<Integer>().error("关联公司失败!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Integer> addWechatUserRelation(VehicleWechatUserRelation relation) {
|
||||
@ -99,8 +111,8 @@ public class VehicleServiceImpl implements VehicleService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<List<VehicleInfo>> listWechatUserRelation(String openid, String plateNum) {
|
||||
List<VehicleWechatUserRelation> relationList = vehicleWechatUserRelationDao.selectList(new QueryWrapper<VehicleWechatUserRelation>().eq(StringUtils.hasText(openid), "openid", openid));
|
||||
public Result<List<VehicleInfo>> listWechatUserRelation(String wuid, String plateNum) {
|
||||
List<VehicleWechatUserRelation> relationList = vehicleWechatUserRelationDao.selectList(new QueryWrapper<VehicleWechatUserRelation>().eq(StringUtils.hasText(wuid), "ucode", wuid));
|
||||
if (relationList.isEmpty()) {
|
||||
return new Result<List<VehicleInfo>>().error(CodeMsg.DATABASE_RESULT_NULL);
|
||||
}
|
||||
@ -112,4 +124,6 @@ public class VehicleServiceImpl implements VehicleService {
|
||||
return new Result<List<VehicleInfo>>().success(list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -8,6 +8,9 @@
|
||||
<result column="station_code" property="stationCode" />
|
||||
<result column="day_begin" property="dayBegin" />
|
||||
<result column="day_end" property="dayEnd" />
|
||||
<result column="each_km_fee" property="eachKmFee" />
|
||||
<result column="each_soc_fee" property="eachSocFee" />
|
||||
<result column="each_kwh_fee" property="eachKwhFee" />
|
||||
<result column="common_remain_fee" property="commonRemainFee" />
|
||||
<result column="common_remain_soc_range" property="commonRemainSocRange" />
|
||||
<result column="more_remain_soc" property="moreRemainSoc" />
|
||||
@ -26,7 +29,7 @@
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
pk_id, station_code, day_begin, day_end, common_remain_fee, common_remain_soc_range, more_remain_soc, more_remain_fee, few_remain_soc, few_remain_fee, ctime, creater, uptime, updater
|
||||
pk_id, station_code, day_begin, day_end, each_km_fee, each_soc_fee, each_kwh_fee, common_remain_fee, common_remain_soc_range, more_remain_soc, more_remain_fee, few_remain_soc, few_remain_fee, ctime, creater, uptime, updater
|
||||
</sql>
|
||||
|
||||
<select id="listFeeStandard" resultMap="BaseResultMap">
|
||||
@ -36,6 +39,12 @@
|
||||
yt_t_battery_station_hd_fee_standard a
|
||||
where
|
||||
a.station_code = #{stationCode}
|
||||
<if test="day!= null and day != '' ">
|
||||
and a.day_begin <= #{day}
|
||||
</if>
|
||||
<if test="day!= null and day != '' ">
|
||||
and a.day_end >= #{day}
|
||||
</if>
|
||||
order by a.pk_id desc
|
||||
</select>
|
||||
|
||||
|
||||
@ -12,6 +12,9 @@ import org.springframework.web.reactive.config.WebFluxConfigurer;
|
||||
@Configuration
|
||||
public class CorsConfig implements WebFluxConfigurer {
|
||||
|
||||
/**
|
||||
* 这个是servlet里面的,不起作用
|
||||
*/
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**")
|
||||
|
||||
@ -32,11 +32,15 @@ public class MyAccessDeniedHandler implements ServerAccessDeniedHandler {
|
||||
@Override
|
||||
public Mono<Void> handle(ServerWebExchange exchange, AccessDeniedException e) {
|
||||
// log.error("\r\n===>>>" + this.getClass().getName());
|
||||
System.out.println("6666666666");
|
||||
e.printStackTrace();
|
||||
ServerHttpResponse response = exchange.getResponse();
|
||||
response.setStatusCode(HttpStatus.OK);
|
||||
response.getHeaders().add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
|
||||
// 为了解决token过期时,前端不出现跨域错误,添加了一些header,注意Access-Control-Allow-Origin的值
|
||||
response.getHeaders().add("Access-Control-Allow-Origin", "*");
|
||||
response.getHeaders().add("Access-Control-Allow-Credentials", "true");
|
||||
response.getHeaders().add("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS, HEAD");
|
||||
response.getHeaders().add("Access-Control-Allow-Headers", HttpHeaders.AUTHORIZATION);
|
||||
String body= JSONUtil.toJsonStr(new Result<String>().bussinessException(CodeMsg.ACCESS_DENY.getCode(), CodeMsg.ACCESS_DENY.getMsg(), e.getMessage()));
|
||||
DataBuffer buffer = response.bufferFactory().wrap(body.getBytes(Charset.forName("UTF-8")));
|
||||
return response.writeWith(Mono.just(buffer));
|
||||
|
||||
@ -55,6 +55,7 @@ public class MyAuthenticationEntryPoint implements ServerAuthenticationEntryPoin
|
||||
} else if (cause instanceof BadJwtException || cause instanceof JwtEncodingException) {
|
||||
res = new Result<String>().error(CodeMsg.TOKEN_INVALID.getCode(), CodeMsg.TOKEN_INVALID.getMsg(), cause.getMessage());
|
||||
} else if (cause instanceof InvalidBearerTokenException) {
|
||||
System.out.println("8888888");
|
||||
String token = exchange.getRequest().getHeaders().getFirst("Authorization").substring(7);
|
||||
String dateTime = DateUtil.formatDateTime(TokenUtil.getExp(token));
|
||||
res = new Result<String>().bussinessException(CodeMsg.TOKEN_EXPIRED.getCode(), CodeMsg.TOKEN_EXPIRED.getMsg(), "Jwt expired at " + dateTime);
|
||||
|
||||
@ -40,6 +40,7 @@ public class ResourceServerConfig {
|
||||
http.csrf(csrf -> csrf.disable());
|
||||
// 跨域处理
|
||||
http.cors(Customizer.withDefaults());
|
||||
// http.cors(cors -> cors.disable());
|
||||
http.httpBasic(httpBasicSpec -> httpBasicSpec.disable());
|
||||
// 资源服务器配置
|
||||
http.oauth2ResourceServer(server -> server
|
||||
|
||||
@ -6,6 +6,7 @@ import org.springframework.boot.autoconfigure.web.WebProperties.Resources;
|
||||
import org.springframework.boot.autoconfigure.web.reactive.error.DefaultErrorWebExceptionHandler;
|
||||
import org.springframework.boot.web.reactive.error.ErrorAttributes;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.reactive.function.BodyInserters;
|
||||
@ -48,12 +49,17 @@ public class GlobalExceptionHandler extends DefaultErrorWebExceptionHandler {
|
||||
@Override
|
||||
protected Mono<ServerResponse> renderErrorResponse(ServerRequest request) {
|
||||
// Map<String, Object> error = getErrorAttributes(request, getErrorAttributeOptions(request, MediaType.ALL));
|
||||
Throwable throwable = getError(request);
|
||||
return ServerResponse
|
||||
Throwable throwable = getError(request);
|
||||
return ServerResponse
|
||||
// .status(super.getHttpStatus(error))
|
||||
.status(HttpStatus.OK)
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
// .body(BodyInserters.fromValue(new RuntimeException()))
|
||||
// 为了解决token过期时,前端不出现跨域错误,添加了一些header
|
||||
.header("Access-Control-Allow-Origin", "*")
|
||||
.header("Access-Control-Allow-Credentials", "true")
|
||||
.header("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS, HEAD")
|
||||
.header("Access-Control-Allow-Headers", HttpHeaders.AUTHORIZATION)
|
||||
.body(BodyInserters.fromValue(globalExceptionType.handle(throwable)))
|
||||
;
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@ public class GlobalExceptionType {
|
||||
|
||||
@ExceptionHandler(value = {OAuth2AuthorizationException.class})
|
||||
public Result<String> oAuth2AuthorizationHandle(OAuth2AuthorizationException e) {
|
||||
e.printStackTrace();
|
||||
e.printStackTrace();
|
||||
OAuth2Error error = e.getError();
|
||||
return new Result<String>().bussinessException(error.getErrorCode(), error.getDescription(), error.getUri());
|
||||
}
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
package com.evotech.hd.wechat.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springdoc.core.annotations.ParameterObject;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@ -61,6 +63,9 @@ public class CloudServeController {
|
||||
@GetMapping("/order/swap/list")
|
||||
@ApiOperationSupport(order = 7)
|
||||
public Result<List<OrderSwapBattery>> list(@ParameterObject PageListSwapOrderRequest plsor) {
|
||||
if (!StringUtils.hasText(plsor.getUserId())) {
|
||||
return null;
|
||||
}
|
||||
return cloudService.list(plsor);
|
||||
}
|
||||
|
||||
@ -77,5 +82,12 @@ public class CloudServeController {
|
||||
public Result<List<BatteryStationVO>> listStation(@RequestParam(required = false) String plateNum) {
|
||||
return cloudService.listStation(plateNum);
|
||||
}
|
||||
|
||||
@Operation(summary = "公司编码查询公司")
|
||||
@GetMapping("/company/companyByCode")
|
||||
@ApiOperationSupport(order = 10)
|
||||
public Result<Map<String, String>> companyByCode(String ccode) {
|
||||
return cloudService.companyByCode(ccode);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -36,5 +36,12 @@ public class WechatUserController {
|
||||
public Result<WechatUser> userByUid(String wuid) {
|
||||
return wechatUserService.userByUid(wuid);
|
||||
}
|
||||
|
||||
@Operation(summary = "绑定公司")
|
||||
@PostMapping("/bindcompany")
|
||||
public Result<Integer> bindCompany(String wuid, String code, String name) {
|
||||
return wechatUserService.bindCompany(wuid, code, name);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
package com.evotech.hd.wechat.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.cloud.openfeign.SpringQueryMap;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@ -32,7 +34,7 @@ public interface CloudService {
|
||||
|
||||
@GetMapping(value = "/cloud/order/swap/list",
|
||||
consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE})
|
||||
public Result<List<OrderSwapBattery>> list(PageListSwapOrderRequest plsor);
|
||||
public Result<List<OrderSwapBattery>> list(@SpringQueryMap PageListSwapOrderRequest plsor);
|
||||
|
||||
@GetMapping(value = "/cloud/order/swap/step/list",
|
||||
consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE})
|
||||
@ -42,5 +44,9 @@ public interface CloudService {
|
||||
consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE})
|
||||
public Result<List<BatteryStationVO>> listStation(@RequestParam String plateNum);
|
||||
// public Result<List<BatteryStation>> listStation(@SpringQueryMap BasePageRequest bpr);
|
||||
|
||||
@GetMapping(value = "/cloud/company/companyByCode",
|
||||
consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE})
|
||||
public Result<Map<String, String>> companyByCode(@RequestParam String ccode);
|
||||
|
||||
}
|
||||
|
||||
@ -8,5 +8,7 @@ public interface WechatUserService {
|
||||
public Result<String> update(WechatUser wuser);
|
||||
|
||||
public Result<WechatUser> userByUid(String wuid);
|
||||
|
||||
public Result<Integer> bindCompany(String wuid, String code, String name);
|
||||
|
||||
}
|
||||
|
||||
@ -22,11 +22,17 @@ public class WechatUserServiceImpl implements WechatUserService {
|
||||
|
||||
@Override
|
||||
public Result<String> update(WechatUser wuser) {
|
||||
int n = wechatUserDao.update(wuser, new QueryWrapper<WechatUser>().eq("wuid", wuser.getWuid()));
|
||||
WechatUser user = new WechatUser();
|
||||
user.setName(wuser.getName());
|
||||
user.setGender(wuser.getGender());
|
||||
user.setNickName(wuser.getNickName());
|
||||
user.setPhoneNumber(wuser.getPhoneNumber());
|
||||
user.setAvatarUrl(wuser.getAvatarUrl());
|
||||
int n = wechatUserDao.update(user, new QueryWrapper<WechatUser>().eq("wuid", wuser.getWuid()));
|
||||
if (n == 1) {
|
||||
return new Result<String>().success(1);
|
||||
}
|
||||
return new Result<String>().error("修改微信用户信息出错");
|
||||
return new Result<String>().error("修改微信用户信息出错!");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -40,4 +46,17 @@ public class WechatUserServiceImpl implements WechatUserService {
|
||||
return new Result<WechatUser>().success(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Integer> bindCompany(String wuid, String code, String name) {
|
||||
WechatUser user = new WechatUser();
|
||||
user.setType(2);
|
||||
user.setPcode(code);
|
||||
user.setPname(name);
|
||||
int n = wechatUserDao.update(user, new QueryWrapper<WechatUser>().eq("wuid", wuid));
|
||||
if (n == 1) {
|
||||
return new Result<Integer>().success(1);
|
||||
}
|
||||
return new Result<Integer>().error("绑定出错!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user