Compare commits

...

4 Commits

Author SHA1 Message Date
Administrator
9354169741 新增订单按电量结算费用逻辑 2024-12-27 17:39:39 +08:00
Administrator
f2921afcc8 1. 调整公司接口
2. 添加公司员工绑定接口
3. 添加公司车辆关联接口
4. 修复mybatis分页查询无总数bug
5. 完善换电站费用标准
6. 完善换电交互逻辑
7. 修改token过期时的返回bug
2024-12-27 17:38:33 +08:00
Administrator
08ef590c4f 补充上一个 2024-12-24 15:32:28 +08:00
Administrator
652fd909df 1. 小程序端查询换电站接口
2. 换电站添加时 增加编码验证,避免重复添加
3. 完善全局异常,添加 MethodArgumentNotValidException 异常
4. 预约订单时,添加车辆、人员检查
5. 完善小程序轮播图接口
6. 完善小程序协议接口
7. 小程序人员 openid、手机号脱敏处理
2024-12-24 15:32:12 +08:00
55 changed files with 852 additions and 63 deletions

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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);
}

View File

@ -35,7 +35,7 @@ public class Oauth2AccessTokenUtil {
tokenRes.setTokenType(jo1.getStr("token_type"));
return tokenRes;
} else {
throw new RuntimeException("生成token出错");
throw new RuntimeException("生成登陆令牌异常!");
}
}

View File

@ -71,6 +71,13 @@ public class BatteryStation implements Serializable {
@Schema(description = "联系电话")
private String phone;
@Schema(description = "服务车辆类型")
private String carTypeCode;
@Schema(description = "是否适合该车辆")
@TableField(exist = false)
private Boolean isSuitable;
@Schema(description = "删除标识1-已删除0-未删除")
private Integer delFlag;

View File

@ -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 = "当前电量")

View File

@ -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;

View File

@ -1,4 +1,4 @@
package com.evotech.hd.resource.entity;
package com.evotech.hd.common.core.entity.cloud;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
@ -73,7 +73,7 @@ public class Company implements Serializable {
@Schema(description = "状态1-启用0-禁用")
private Integer status;
@Schema(description = "删除标识1-已删除0-未删除")
@Schema(description = "删除标识1-已删除0-未删除", hidden = true)
private Integer delFlag;
@Schema(description = "账户余额")

View File

@ -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;

View File

@ -64,6 +64,7 @@ public class OrderSwapBatteryPre implements Serializable {
private Date reservationTime;
@Schema(description = "预约换电日期", example = "yyyyMMdd", requiredMode = RequiredMode.REQUIRED)
@NotBlank
private String swapDay;
@Schema(description = "预约换电时间段", example = "8:00-10:00")

View File

@ -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;

View File

@ -0,0 +1,62 @@
package com.evotech.hd.common.core.entity.cloud.vo;
import java.io.Serializable;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(name = "小程序查询换电站返回结果")
public class BatteryStationVO implements Serializable {
private static final long serialVersionUID = 4629351941147810984L;
@Schema(description = "站点名称")
private String name;
@Schema(description = "站点编码")
private String code;
@Schema(description = "状态1-正常营业2-正常停运3-故障停运4-指令停运9-其它")
private Integer status;
@Schema(description = "站点类型ID")
private Integer type;
@Schema(description = "地址")
private String address;
@Schema(description = "地址-省")
private String addressProvince;
@Schema(description = "地址-市")
private String addressCity;
@Schema(description = "地址-区县")
private String addressArea;
@Schema(description = "注册日期")
private String registerDate;
@Schema(description = "联系人")
private String contacts;
@Schema(description = "联系电话")
private String phone;
@Schema(description = "服务车辆类型")
private String carTypeCode;
@Schema(description = "是否适合该车辆")
private Boolean isSuitable;
@Schema(description = "激活日期")
private String activeDate;
@Schema(description = "经纬度信息")
private String locationPoint;
@Schema(description = "全天营业1-是0-否")
private Integer openAllDay;
}

View File

@ -45,7 +45,8 @@ public class WechatAgreement implements Serializable {
@NotBlank
private String content;
@Schema(description = "版本")
@Schema(description = "版本", requiredMode = RequiredMode.REQUIRED)
@NotBlank
private String version;
@Schema(description = "状态1-可用0-不可用")

View File

@ -0,0 +1,25 @@
package com.evotech.hd.common.mybatis.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
@Configuration
public class MybatisPlusConfig {
/**
* 添加分页插件
*/
@Bean
MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
// 如果配置多个插件, 切记分页最后添加
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
// 如果有多数据源可以不配具体类型, 否则都建议配上具体的 DbType
return interceptor;
}
}

View File

@ -1,7 +1,10 @@
package com.evotech.hd.common.web.exception;
import java.util.stream.Collectors;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
@ -32,7 +35,7 @@ public class GlobalExceptionHandler {
*/
@ExceptionHandler(value = NullPointerException.class)
public Result<String> exceptionHandler(HttpServletRequest req, NullPointerException e) {
log.error("空指针异常:", e);
log.error("\r\n===>>>空指针异常:", e);
return new Result<String>().bussinessException(CodeMsg.ERROR.getCode(), e.getMessage(), null);
}
@ -42,7 +45,7 @@ public class GlobalExceptionHandler {
*/
@ExceptionHandler(value = HttpMessageNotReadableException.class)
public Result<String> exceptionHandler(HttpServletRequest req, HttpMessageNotReadableException e) {
log.error("http请求参数解析异常", e);
log.error("\r\n===>>>http请求参数解析异常", e);
return new Result<String>().bussinessException(CodeMsg.PARAM_ERROR.getCode(), "http请求参数解析异常", e.getMessage());
}
@ -53,7 +56,7 @@ public class GlobalExceptionHandler {
*/
@ExceptionHandler(value = MyArgumentException.class)
public Result<String> exceptionHandler(HttpServletRequest req, MyArgumentException e) {
log.error("请求参数异常:", e);
log.error("\r\n===>>>请求参数异常:", e);
return new Result<String>().bussinessException(CodeMsg.PARAM_ERROR.getCode(), CodeMsg.PARAM_ERROR.getMsg(), e.getParamArr());
}
@ -66,18 +69,28 @@ public class GlobalExceptionHandler {
*/
@ExceptionHandler(value = DataIntegrityViolationException.class)
public Result<String> exceptionHandler(HttpServletRequest req, DataIntegrityViolationException e) {
log.error("sql语句异常", e);
log.error("\r\n===>>>sql语句异常", e);
return new Result<String>().bussinessException(CodeMsg.SQL_RUN_ERROR.getCode(), e.getCause().toString(), null);
}
/**
* @Valid抛出的参数异常
*/
@ExceptionHandler(value = MethodArgumentNotValidException.class)
public Result<String> exceptionHandler(HttpServletRequest req, MethodArgumentNotValidException e) {
log.error("\r\n===>>>传参 自动检测出 错误:", e);
String param = e.getBindingResult().getFieldErrors().stream().map(i -> i.getField()).collect(Collectors.joining(","));
return new Result<String>().bussinessException(CodeMsg.PARAM_ERROR.getCode(), param, e.getBindingResult().getFieldErrors());
}
/**
* 自己抛出的运行异常
* @param req
* @param e
*/
@ExceptionHandler(value = Exception.class)
public Result<String> exceptionHandler(HttpServletRequest req, RuntimeException e) {
log.error("捕获运行异常:", e);
public Result<String> exceptionHandler(HttpServletRequest req, Exception e) {
log.error("\r\n===>>>捕获运行异常:", e);
return new Result<String>().bussinessException(CodeMsg.ERROR.getCode(), e instanceof RuntimeException?e.getMessage():e.toString(), null);
}

View File

@ -14,9 +14,11 @@ import com.evotech.hd.cloud.entity.request.PageListBatteryStationRequest;
import com.evotech.hd.cloud.service.BatteryStationService;
import com.evotech.hd.common.core.entity.Result;
import com.evotech.hd.common.core.entity.cloud.BatteryStation;
import com.evotech.hd.common.core.entity.cloud.vo.BatteryStationVO;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
@ -60,6 +62,13 @@ public class BatteryStationController {
return batteryStationService.list(plbsr);
}
@Operation(summary = "查询2")
@GetMapping("/liststation")
@Hidden
public Result<List<BatteryStationVO>> listStation(@RequestParam(required = false) String plateNum) {
return batteryStationService.listStation(plateNum);
}
@Operation(summary = "站点秘钥")
@PostMapping("/rsa_secret_key")

View File

@ -1,6 +1,7 @@
package com.evotech.hd.resource.controller;
package com.evotech.hd.cloud.controller.customer;
import java.util.List;
import java.util.Map;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.web.bind.annotation.GetMapping;
@ -8,10 +9,10 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.evotech.hd.cloud.service.CompanyService;
import com.evotech.hd.common.core.entity.BasePageRequest;
import com.evotech.hd.common.core.entity.Result;
import com.evotech.hd.resource.entity.Company;
import com.evotech.hd.resource.service.CompanyService;
import com.evotech.hd.common.core.entity.cloud.Company;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
@ -23,8 +24,8 @@ import jakarta.validation.constraints.NotNull;
@Tag(name = "公司管理")
@RestController
@RequestMapping("/system/company")
@ApiSupport(order = 84)
@RequestMapping("/company")
@ApiSupport(order = 33)
public class CompanyController {
@ -59,5 +60,10 @@ public class CompanyController {
public Result<List<Company>> list(@Valid @ParameterObject BasePageRequest bpr) {
return companyService.list(bpr);
}
@GetMapping("/companyByCode")
public Result<Map<String, String>> companyByCode(String ccode) {
return companyService.companyByCode(ccode);
}
}

View File

@ -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);
}
}

View File

@ -1,4 +1,4 @@
package com.evotech.hd.cloud.controller;
package com.evotech.hd.cloud.controller.customer;
import java.util.List;
@ -21,7 +21,7 @@ import jakarta.annotation.Resource;
@Tag(name = "微信用户")
@RestController
@RequestMapping("/wechat/user")
@ApiSupport(order = 11)
@ApiSupport(order = 32)
public class WechatUserController {
@Resource

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -1,7 +1,7 @@
package com.evotech.hd.resource.dao;
package com.evotech.hd.cloud.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.evotech.hd.resource.entity.Company;
import com.evotech.hd.common.core.entity.cloud.Company;
/**
* @author zrb

View File

@ -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);
}
// 返回数据

View File

@ -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);

View File

@ -6,6 +6,7 @@ import java.util.Map;
import com.evotech.hd.cloud.entity.request.PageListBatteryStationRequest;
import com.evotech.hd.common.core.entity.Result;
import com.evotech.hd.common.core.entity.cloud.BatteryStation;
import com.evotech.hd.common.core.entity.cloud.vo.BatteryStationVO;
public interface BatteryStationService {
@ -17,6 +18,8 @@ public interface BatteryStationService {
public Result<List<BatteryStation>> list(PageListBatteryStationRequest plbsr);
public Result<List<BatteryStationVO>> listStation(String plateNum);
public Result<Map<String, String>> RsaSecretKey(String stationCode);
}

View File

@ -1,10 +1,11 @@
package com.evotech.hd.resource.service;
package com.evotech.hd.cloud.service;
import java.util.List;
import java.util.Map;
import com.evotech.hd.common.core.entity.BasePageRequest;
import com.evotech.hd.common.core.entity.Result;
import com.evotech.hd.resource.entity.Company;
import com.evotech.hd.common.core.entity.cloud.Company;
public interface CompanyService {
@ -15,5 +16,7 @@ public interface CompanyService {
public Result<Integer> update(Company company);
public Result<List<Company>> list(BasePageRequest bpr);
public Result<Map<String, String>> companyByCode(String ccode);
}

View File

@ -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);
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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) {

View File

@ -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);
}

View File

@ -7,17 +7,23 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
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.BatteryStationDao;
import com.evotech.hd.cloud.dao.BatteryStationSecretKeyDao;
import com.evotech.hd.cloud.dao.VehicleInfoDao;
import com.evotech.hd.cloud.entity.BatteryStationSecretKey;
import com.evotech.hd.cloud.entity.request.PageListBatteryStationRequest;
import com.evotech.hd.cloud.service.BatteryStationService;
import com.evotech.hd.common.core.entity.Result;
import com.evotech.hd.common.core.entity.cloud.BatteryStation;
import com.evotech.hd.common.core.entity.cloud.VehicleInfo;
import com.evotech.hd.common.core.entity.cloud.vo.BatteryStationVO;
import com.evotech.hd.common.core.enums.CodeMsg;
import cn.hutool.crypto.KeyUtil;
@ -31,10 +37,18 @@ public class BatteryStationServiceImpl implements BatteryStationService {
private BatteryStationDao batteryStationDao;
@Resource
private BatteryStationSecretKeyDao batteryStationSecretKeyDao;
@Resource
private VehicleInfoDao vehicleInfoDao;
@Override
public Result<Integer> add(BatteryStation bs) {
bs.setCtime(new Date());
boolean b = batteryStationDao.exists(new QueryWrapper<BatteryStation>()
.eq("del_flag", 0)
.eq("code", bs.getCode()));
if (b) {
return new Result<Integer>().error("换电站已存在!");
}
int n = batteryStationDao.insert(bs);
if (n == 1) {
return new Result<Integer>().success(n);
@ -105,4 +119,37 @@ public class BatteryStationServiceImpl implements BatteryStationService {
return new Result<Map<String,String>>().success(map);
}
@Override
public Result<List<BatteryStationVO>> listStation(String plateNum) {
List<BatteryStation> list = batteryStationDao.selectList(new QueryWrapper<BatteryStation>().eq("del_flag", 0));
if (list.isEmpty()) {
return new Result<List<BatteryStationVO>>().error(CodeMsg.DATABASE_RESULT_NULL);
}
List<BatteryStationVO> res = list.stream().map(i -> {
BatteryStationVO vo = new BatteryStationVO();
BeanUtils.copyProperties(i, vo);
return vo;
}).toList();
if (StringUtils.hasText(plateNum)) {
VehicleInfo vi = vehicleInfoDao.selectOne(new QueryWrapper<VehicleInfo>()
.eq("del_flag", 0)
.eq("plate_num", plateNum));
if (vi == null) {
return new Result<List<BatteryStationVO>>().error("无车辆信息!");
}
res = res.stream().map(i -> {
if (StringUtils.hasText(i.getCarTypeCode()) && i.getCarTypeCode().contains(vi.getTypeCode())) {
i.setIsSuitable(true);
}
return i;
})
.sorted((i1, i2) -> i1.getIsSuitable().compareTo(i2.getIsSuitable()))
.toList();
}
return new Result<List<BatteryStationVO>>().success(res);
}
}

View File

@ -1,19 +1,20 @@
package com.evotech.hd.resource.service.impl;
package com.evotech.hd.cloud.service.impl;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.evotech.hd.cloud.dao.CompanyDao;
import com.evotech.hd.cloud.service.CompanyService;
import com.evotech.hd.common.core.entity.BasePageRequest;
import com.evotech.hd.common.core.entity.Result;
import com.evotech.hd.common.core.entity.cloud.Company;
import com.evotech.hd.common.core.enums.CodeMsg;
import com.evotech.hd.resource.dao.CompanyDao;
import com.evotech.hd.resource.entity.Company;
import com.evotech.hd.resource.service.CompanyService;
import jakarta.annotation.Resource;
@ -65,4 +66,16 @@ public class CompanyServiceImpl implements CompanyService {
return new Result<List<Company>>().success(page);
}
@Override
public Result<Map<String, String>> companyByCode(String ccode) {
Company one = companyDao.selectOne(new QueryWrapper<Company>().eq("ccode", ccode));
if (one == null) {
return new Result<Map<String, String>>().error(CodeMsg.DATABASE_RESULT_NULL);
}
Map<String, String> m = new HashMap<String, String>();
m.put("ccode", one.getCcode());
m.put("cname", one.getCname());
return new Result<Map<String, String>>().success(m);
}
}

View File

@ -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;
@ -12,12 +15,16 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.evotech.hd.cloud.dao.OrderSwapBatteryDao;
import com.evotech.hd.cloud.dao.OrderSwapBatteryPreDao;
import com.evotech.hd.cloud.dao.OrderSwapBatteryStepDao;
import com.evotech.hd.cloud.dao.VehicleInfoDao;
import com.evotech.hd.cloud.service.OrderSwapBatteryService;
import com.evotech.hd.common.core.dao.wechat.WechatUserDao;
import com.evotech.hd.common.core.entity.Result;
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.OrderSwapBatteryStep;
import com.evotech.hd.common.core.entity.cloud.PageListSwapOrderRequest;
import com.evotech.hd.common.core.entity.cloud.VehicleInfo;
import com.evotech.hd.common.core.entity.wechat.WechatUser;
import com.evotech.hd.common.core.enums.CodeMsg;
import jakarta.annotation.Resource;
@ -31,13 +38,32 @@ public class OrderSwapBatteryServiceImpl implements OrderSwapBatteryService {
private OrderSwapBatteryPreDao orderSwapBatteryPreDao;
@Resource
private OrderSwapBatteryStepDao orderSwapBatteryStepDao;
@Resource
private VehicleInfoDao vehicleInfoDao;
@Resource
private WechatUserDao wechatUserDao;
@Override
public Result<Integer> addPre(OrderSwapBatteryPre osbp) {
// 1. 检查车辆
boolean b1 = vehicleInfoDao.exists(new QueryWrapper<VehicleInfo>()
.eq("del_flag", 0)
.eq("plate_num", osbp.getPlateNum()));
if (!b1) {
return new Result<Integer>().error("车辆未注册!");
}
// 2. 检查预约人
boolean b2 = wechatUserDao.exists(new QueryWrapper<WechatUser>()
.ne("phone_number", "")
.isNotNull("phone_number")
.eq("wuid", osbp.getUcode()));
if (!b2) {
return new Result<Integer>().error("用户认证信息不全!");
}
// 是否需要验证人和车绑定关系
// 是否需要验证公司和车的绑定关系
// 3. 添加预约
Date d = new Date();
@ -112,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);
}
@ -140,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);
}
}

View File

@ -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);
}
}

View File

@ -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 &lt;= #{day}
</if>
<if test="day!= null and day != '' ">
and a.day_end &gt;= #{day}
</if>
order by a.pk_id desc
</select>

View File

@ -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("/**")

View File

@ -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));

View File

@ -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);

View File

@ -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

View File

@ -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)))
;

View File

@ -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());
}

View File

@ -1,6 +1,64 @@
package com.evotech.hd.resource.controller;
import java.util.List;
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.common.core.entity.Result;
import com.evotech.hd.common.core.entity.resource.WechatAgreement;
import com.evotech.hd.resource.service.WechatAgreementService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
@Tag(name = "微信协议")
@RestController
@RequestMapping("/wechat/agreement")
@ApiSupport(order = 201)
public class WechatAgreementController {
@Resource
private WechatAgreementService wechatAgreementService;
@Operation(summary = "增加")
@PostMapping("/add")
@ApiOperationSupport(order = 1)
public Result<Integer> add(@Valid @ParameterObject WechatAgreement wa) {
return wechatAgreementService.add(wa);
}
@Operation(summary = "删除")
@PostMapping("/del")
@ApiOperationSupport(order = 2)
public Result<Integer> delete(@NotNull Integer id) {
return wechatAgreementService.delete(id);
}
@Operation(summary = "修改")
@PostMapping({"/update"})
@ApiOperationSupport(order = 3)
public Result<Integer> update(@ParameterObject WechatAgreement wa) {
return wechatAgreementService.update(wa);
}
@Operation(summary = "查询")
@GetMapping("/list")
@ApiOperationSupport(order = 4)
public Result<List<WechatAgreement>> list(@RequestParam String appid, @RequestParam Integer type, @RequestParam Integer status) {
return wechatAgreementService.list(appid, type, status);
}
}

View File

@ -1,5 +1,63 @@
package com.evotech.hd.resource.controller;
import java.util.List;
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.common.core.entity.Result;
import com.evotech.hd.common.core.entity.resource.WechatSwiper;
import com.evotech.hd.resource.service.WechatSwiperService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
@Tag(name = "微信轮播图")
@RestController
@RequestMapping("/wechat/swiper")
@ApiSupport(order = 202)
public class WechatSwiperController {
@Resource
private WechatSwiperService wechatSwiperService;
@Operation(summary = "增加")
@PostMapping("/add")
@ApiOperationSupport(order = 1)
public Result<Integer> add(@Valid @ParameterObject WechatSwiper ws) {
return wechatSwiperService.add(ws);
}
@Operation(summary = "删除")
@PostMapping("/del")
@ApiOperationSupport(order = 2)
public Result<Integer> delete(@NotNull Integer id) {
return wechatSwiperService.delete(id);
}
@Operation(summary = "修改")
@PostMapping({"/update"})
@ApiOperationSupport(order = 3)
public Result<Integer> update(@ParameterObject WechatSwiper ws) {
return wechatSwiperService.update(ws);
}
@Operation(summary = "查询")
@GetMapping("/list")
@ApiOperationSupport(order = 4)
public Result<List<WechatSwiper>> list(@RequestParam String appid, @RequestParam Integer type, @RequestParam Integer status) {
return wechatSwiperService.list(appid, type, status);
}
}

View File

@ -0,0 +1,19 @@
package com.evotech.hd.resource.service;
import java.util.List;
import com.evotech.hd.common.core.entity.Result;
import com.evotech.hd.common.core.entity.resource.WechatAgreement;
public interface WechatAgreementService {
public Result<Integer> add(WechatAgreement wa);
public Result<Integer> delete(Integer id);
public Result<Integer> update(WechatAgreement wa);
public Result<List<WechatAgreement>> list(String appid, Integer type, Integer status);
}

View File

@ -0,0 +1,19 @@
package com.evotech.hd.resource.service;
import java.util.List;
import com.evotech.hd.common.core.entity.Result;
import com.evotech.hd.common.core.entity.resource.WechatSwiper;
public interface WechatSwiperService {
public Result<Integer> add(WechatSwiper ws);
public Result<Integer> delete(Integer id);
public Result<Integer> update(WechatSwiper ws);
public Result<List<WechatSwiper>> list(String appid, Integer type, Integer status);
}

View File

@ -0,0 +1,64 @@
package com.evotech.hd.resource.service.impl;
import java.util.Date;
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.evotech.hd.common.core.entity.Result;
import com.evotech.hd.common.core.entity.resource.WechatAgreement;
import com.evotech.hd.common.core.enums.CodeMsg;
import com.evotech.hd.resource.dao.WechatAgreementDao;
import com.evotech.hd.resource.service.WechatAgreementService;
import jakarta.annotation.Resource;
@Service
public class WechatAgreementServiceImpl implements WechatAgreementService {
@Resource
private WechatAgreementDao wechatAgreementDao;
@Override
public Result<Integer> add(WechatAgreement wa) {
wa.setCtime(new Date());
int n = wechatAgreementDao.insert(wa);
if (n == 1) {
return new Result<Integer>().success(n);
}
return new Result<Integer>().error("添加协议出错!");
}
@Override
public Result<Integer> delete(Integer id) {
int n = wechatAgreementDao.deleteById(id);
if (n == 1) {
return new Result<Integer>().success(n);
}
return new Result<Integer>().error("删除协议出错!");
}
@Override
public Result<Integer> update(WechatAgreement wa) {
int n = wechatAgreementDao.updateById(wa);
if (n == 1) {
return new Result<Integer>().success(n);
}
return new Result<Integer>().error("更新类型失败!");
}
@Override
public Result<List<WechatAgreement>> list(String appid, Integer type, Integer status) {
List<WechatAgreement> list = wechatAgreementDao.selectList(new QueryWrapper<WechatAgreement>()
.eq(type != null, "type", type)
.eq(status != null, "status", status)
.eq(StringUtils.hasText(appid), "appid", appid));
if (list.isEmpty()) {
return new Result<List<WechatAgreement>>().error(CodeMsg.DATABASE_RESULT_NULL);
}
return new Result<List<WechatAgreement>>().success(list);
}
}

View File

@ -0,0 +1,64 @@
package com.evotech.hd.resource.service.impl;
import java.util.Date;
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.evotech.hd.common.core.entity.Result;
import com.evotech.hd.common.core.entity.resource.WechatSwiper;
import com.evotech.hd.common.core.enums.CodeMsg;
import com.evotech.hd.resource.dao.WechatSwiperDao;
import com.evotech.hd.resource.service.WechatSwiperService;
import jakarta.annotation.Resource;
@Service
public class WechatSwiperServiceImpl implements WechatSwiperService {
@Resource
private WechatSwiperDao wechatSwiperDao;
@Override
public Result<Integer> add(WechatSwiper ws) {
ws.setCtime(new Date());
int n = wechatSwiperDao.insert(ws);
if (n == 1) {
return new Result<Integer>().success(n);
}
return new Result<Integer>().error("添加轮播图出错!");
}
@Override
public Result<Integer> delete(Integer id) {
int n = wechatSwiperDao.deleteById(id);
if (n == 1) {
return new Result<Integer>().success(n);
}
return new Result<Integer>().error("删除轮播图出错!");
}
@Override
public Result<Integer> update(WechatSwiper ws) {
int n = wechatSwiperDao.updateById(ws);
if (n == 1) {
return new Result<Integer>().success(n);
}
return new Result<Integer>().error("更新类型失败!");
}
@Override
public Result<List<WechatSwiper>> list(String appid, Integer type, Integer status) {
List<WechatSwiper> list = wechatSwiperDao.selectList(new QueryWrapper<WechatSwiper>()
.eq(type != null, "type", type)
.eq(status != null, "status", status)
.eq(StringUtils.hasText(appid), "appid", appid));
if (list.isEmpty()) {
return new Result<List<WechatSwiper>>().error(CodeMsg.DATABASE_RESULT_NULL);
}
return new Result<List<WechatSwiper>>().success(list);
}
}

View File

@ -1,11 +1,14 @@
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;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.evotech.hd.common.core.entity.Result;
@ -13,6 +16,7 @@ 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.OrderSwapBatteryStep;
import com.evotech.hd.common.core.entity.cloud.PageListSwapOrderRequest;
import com.evotech.hd.common.core.entity.cloud.vo.BatteryStationVO;
import com.evotech.hd.wechat.service.CloudService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
@ -51,7 +55,7 @@ public class CloudServeController {
@Operation(summary = "查询预约")
@GetMapping("/order/swap/pre/list")
@ApiOperationSupport(order = 3)
public Result<List<OrderSwapBatteryPre>> listPre(String plateNum, Integer status, String ucode, String stationCode) {
public Result<List<OrderSwapBatteryPre>> listPre(@RequestParam(required = false) String plateNum, @RequestParam(required = false) Integer status, @RequestParam(required = false) String ucode, @RequestParam(required = false) String stationCode) {
return cloudService.listPre(plateNum, status, ucode, stationCode);
}
@ -59,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);
}
@ -68,5 +75,19 @@ public class CloudServeController {
public Result<List<OrderSwapBatteryStep>> listStep(@NotBlank String orderNo) {
return cloudService.listStep(orderNo);
}
@Operation(summary = "查询换电站")
@GetMapping("/station/list")
@ApiOperationSupport(order = 9)
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);
}
}

View File

@ -0,0 +1,47 @@
package com.evotech.hd.wechat.controller;
import java.util.List;
import org.springframework.web.bind.annotation.GetMapping;
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.common.core.entity.Result;
import com.evotech.hd.common.core.entity.resource.WechatAgreement;
import com.evotech.hd.common.core.entity.resource.WechatSwiper;
import com.evotech.hd.wechat.service.ResourceService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
@Tag(name = "资源服务API")
@ApiSupport(order = 14)
@RestController
@RequestMapping("/resource")
public class ResourceServerController {
@Resource
private ResourceService resourceService;
@Operation(summary = "小程序协议查询")
@GetMapping("/agreement/list")
@ApiOperationSupport(order = 1)
public Result<List<WechatAgreement>> listAgreement(@NotBlank @RequestParam String appid, @NotNull @RequestParam Integer type) {
return resourceService.listAgreement(appid, type, 1);
}
@Operation(summary = "小程序轮播图查询")
@GetMapping("/swiper/list")
@ApiOperationSupport(order = 2)
public Result<List<WechatSwiper>> listSwiper(@NotBlank @RequestParam String appid, @NotNull @RequestParam Integer type) {
return resourceService.listSwiper(appid, type, 1);
}
}

View File

@ -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);
}
}

View File

@ -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;
@ -13,6 +15,7 @@ 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.OrderSwapBatteryStep;
import com.evotech.hd.common.core.entity.cloud.PageListSwapOrderRequest;
import com.evotech.hd.common.core.entity.cloud.vo.BatteryStationVO;
@FeignClient(value = "cloud-server")
public interface CloudService {
@ -31,10 +34,19 @@ 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})
public Result<List<OrderSwapBatteryStep>> listStep(String orderNo);
public Result<List<OrderSwapBatteryStep>> listStep(@RequestParam String orderNo);
@GetMapping(value = "/cloud/batterystation/liststation",
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);
}

View File

@ -0,0 +1,24 @@
package com.evotech.hd.wechat.service;
import java.util.List;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import com.evotech.hd.common.core.entity.Result;
import com.evotech.hd.common.core.entity.resource.WechatAgreement;
import com.evotech.hd.common.core.entity.resource.WechatSwiper;
@FeignClient(value = "resource-server")
public interface ResourceService {
@GetMapping(value = "/resource/wechat/agreement/list",
consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE})
public Result<List<WechatAgreement>> listAgreement(@RequestParam String appid, @RequestParam Integer type, @RequestParam Integer status);
@GetMapping(value = "/resource/wechat/swiper/list",
consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE})
public Result<List<WechatSwiper>> listSwiper(@RequestParam String appid, @RequestParam Integer type, @RequestParam Integer status);
}

View File

@ -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);
}

View File

@ -9,6 +9,7 @@ import com.evotech.hd.common.core.entity.wechat.WechatUser;
import com.evotech.hd.common.core.enums.CodeMsg;
import com.evotech.hd.wechat.service.WechatUserService;
import cn.hutool.core.util.DesensitizedUtil;
import jakarta.annotation.Resource;
@ -21,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
@ -34,7 +41,22 @@ public class WechatUserServiceImpl implements WechatUserService {
if (user == null) {
return new Result<WechatUser>().error(CodeMsg.DATABASE_RESULT_NULL);
}
user.setOpenid(DesensitizedUtil.idCardNum(user.getOpenid(), 5, 6));
user.setPhoneNumber(DesensitizedUtil.mobilePhone(user.getPhoneNumber()));
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("绑定出错!");
}
}