添加卡微服务,卡启动前提条件
This commit is contained in:
parent
e6aa02a4a7
commit
4f2f3b0d15
@ -106,9 +106,90 @@ public class Constants
|
||||
* 资源映射路径 前缀
|
||||
*/
|
||||
public static final String RESOURCE_PREFIX = "/profile";
|
||||
|
||||
/**
|
||||
* 帐户不足
|
||||
*/
|
||||
public static final String INSUFFICIENT_ACCOUNT = "insufficient account";
|
||||
|
||||
/**
|
||||
* 锁定帐户
|
||||
*/
|
||||
public static final String LOCKED_ACCOUNT = "locked account";
|
||||
|
||||
/**
|
||||
* 无效终端
|
||||
*/
|
||||
public static final String LNVALID_TERMINAL = "lnvalid terminal";
|
||||
|
||||
/**
|
||||
* 无效运营商(桩的运营商和卡不对应)
|
||||
*/
|
||||
public static final String LNVALID_OPERATOR = "lnvalid operator";
|
||||
|
||||
/**
|
||||
* 无效卡
|
||||
*/
|
||||
public static final String LNVALID_CARD = "lnvalid card";
|
||||
|
||||
/**
|
||||
* 无效用户
|
||||
*/
|
||||
public static final String LNVALID_USER = "lnvalid user";
|
||||
|
||||
/**
|
||||
* 离线卡
|
||||
*/
|
||||
public static final String OFFLINE_CARD = "offline card";
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
*/
|
||||
public static final String ZERO_CARD = "zero card";
|
||||
|
||||
/**
|
||||
* 正常
|
||||
*/
|
||||
public static final String ONE_CARD = "one card";
|
||||
|
||||
/**
|
||||
* 锁卡
|
||||
*/
|
||||
public static final String TWO_CARD = "two card";
|
||||
/**
|
||||
* 挂失
|
||||
*/
|
||||
public static final String THREE_CARD = "three card";
|
||||
/**
|
||||
* 作废
|
||||
*/
|
||||
public static final String FOUR_CARD = "four card";
|
||||
|
||||
//你有异常订单未解决,请拨打客服电话进行解决
|
||||
public static final String EXCEPTION_ORDER = "exception order";
|
||||
|
||||
//你有申请退款订单在审核中,需要充电请取消申请退款
|
||||
public static final String REFUND_ORDER = "refund order";
|
||||
|
||||
//车辆正在充电,请查询车辆充电信息
|
||||
public static final String CHARGE_ORDER = "charge order";
|
||||
|
||||
//未注册的终端,请选择其他终端充电
|
||||
public static final String UNREGISTERED_TERMINAL = "unregistered terminal";
|
||||
|
||||
//未知的终端状态,请选择其他终端充电
|
||||
public static final String UNKNOWN_TERMINAL = "unknown terminal";
|
||||
|
||||
//离线终端
|
||||
public static final String OFFLINE_TERMINAL = "offline terminal";
|
||||
|
||||
//故障终端
|
||||
public static final String FAULT_TERMINAL = "fault terminal";
|
||||
|
||||
//充电终端
|
||||
public static final String CHARGE_TERMINAL = "charge terminal";
|
||||
|
||||
//未知的枪
|
||||
public static final String UNKNOWN_GUN = "unknown gun";
|
||||
|
||||
//请插好充电枪
|
||||
public static final String INSERT_THE_GUN = "insert the gun";
|
||||
}
|
||||
|
||||
@ -59,4 +59,9 @@ public class ServiceNameConstants {
|
||||
*/
|
||||
public static final String XHPC_CARD ="xhpc-card";
|
||||
|
||||
/**
|
||||
* 电站服务
|
||||
*/
|
||||
public static final String XHPC_CHARGING_STATION ="xhpc-charging-station";
|
||||
|
||||
}
|
||||
|
||||
@ -72,11 +72,21 @@
|
||||
<artifactId>ruoyi-common-log</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-core</artifactId>
|
||||
</dependency>
|
||||
<!-- RuoYi Common Swagger -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-swagger</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>xhpc-common</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package com.xhpc.job;
|
||||
package com.xhpc;
|
||||
|
||||
import com.xhpc.common.security.annotation.EnableCustomConfig;
|
||||
import com.xhpc.common.security.annotation.EnableRyFeignClients;
|
||||
@ -0,0 +1,30 @@
|
||||
package com.xhpc.job.service;
|
||||
|
||||
import com.xhpc.common.api.UserTypeService;
|
||||
import com.xhpc.common.core.domain.R;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author yuyang
|
||||
* @date 2022/1/24 13:32
|
||||
*/
|
||||
@Service
|
||||
public class CardJobServiceImpl implements ICardJobService{
|
||||
|
||||
|
||||
@Autowired
|
||||
private UserTypeService userTypeService;
|
||||
|
||||
@Override
|
||||
public void cardStartup(String phone, String tenantId) {
|
||||
R user = userTypeService.getUser(phone, null, null, null,tenantId);
|
||||
if(user !=null && user.getData() !=null){
|
||||
Map<String, Object> map = (Map<String, Object>)user.getData();
|
||||
System.out.println("执行方法11有参方法map:" + map.toString());
|
||||
}
|
||||
System.out.println("执行方法结束");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
package com.xhpc.job.service;
|
||||
|
||||
/**
|
||||
* @author yuyang
|
||||
* @date 2022/1/24 13:31
|
||||
*/
|
||||
public interface ICardJobService {
|
||||
|
||||
public void cardStartup(String phone, String tenantId);
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
package com.xhpc.job.task;
|
||||
import com.xhpc.job.service.ICardJobService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author yuyang
|
||||
* @date 2022/1/24 11:26
|
||||
*/
|
||||
@Component("cardTask")
|
||||
public class CardTask {
|
||||
|
||||
@Autowired
|
||||
ICardJobService cardJobService;
|
||||
|
||||
public void cardStartup(String cardNumber, String serialNumber){
|
||||
System.out.println("执行方法11有参方法cardNumber:" + cardNumber);
|
||||
System.out.println("执行方法11有参方法serialNumber:" + serialNumber);
|
||||
cardJobService.cardStartup(cardNumber,serialNumber);
|
||||
}
|
||||
|
||||
public void cardSotup(String phone, String tenantId){
|
||||
System.out.println("执行方法22有参方法phone:" + phone);
|
||||
System.out.println("执行方法22有参方法tenantId:" + tenantId);
|
||||
System.out.println("55555");
|
||||
}
|
||||
}
|
||||
@ -20,6 +20,7 @@
|
||||
<module>xhpc-invoice</module>
|
||||
<module>xhpc-tradebill</module>
|
||||
<module>xhpc-message-board</module>
|
||||
<module>xhpc-card</module>
|
||||
</modules>
|
||||
|
||||
<artifactId>xhpc-modules</artifactId>
|
||||
|
||||
119
xhpc-modules/xhpc-card/pom.xml
Normal file
119
xhpc-modules/xhpc-card/pom.xml
Normal file
@ -0,0 +1,119 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>xhpc-modules</artifactId>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<version>3.0.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>xhpc-card</artifactId>
|
||||
|
||||
<description>
|
||||
卡服务
|
||||
</description>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-security</artifactId>
|
||||
</dependency>
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos Config -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Sentinel -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Mysql Connector -->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common DataSource -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-datasource</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common DataScope -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-datascope</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>xhpc-common</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.shiro</groupId>
|
||||
<artifactId>shiro-core</artifactId>
|
||||
<version>1.4.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-log</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/java</directory>
|
||||
<includes>
|
||||
<include>**/*.xml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>2.4.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@ -0,0 +1,33 @@
|
||||
package com.xhpc;
|
||||
|
||||
import com.xhpc.common.security.annotation.EnableCustomConfig;
|
||||
import com.xhpc.common.security.annotation.EnableRyFeignClients;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
/**
|
||||
* @author yuyang
|
||||
* @date 2022/1/19 17:52
|
||||
*/
|
||||
@EnableCustomConfig
|
||||
@EnableRyFeignClients
|
||||
@EnableFeignClients
|
||||
@SpringBootApplication
|
||||
@MapperScan("com.xhpc.card.mapper")
|
||||
public class CardApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(CardApplication.class, args);
|
||||
System.out.println("(♥◠‿◠)ノ゙ 卡服务启动成功 ლ(´ڡ`ლ)゙ \n" +
|
||||
" .-------. ____ __ \n" +
|
||||
" | _ _ \\ \\ \\ / / \n" +
|
||||
" | ( ' ) | \\ _. / ' \n" +
|
||||
" |(_ o _) / _( )_ .' \n" +
|
||||
" | (_,_).' __ ___(_ o _)' \n" +
|
||||
" | |\\ \\ | || |(_,_)' \n" +
|
||||
" | | \\ `' /| `-' / \n" +
|
||||
" | | \\ / \\ / \n" +
|
||||
" ''-' `'-' `-..-' ");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,44 @@
|
||||
package com.xhpc.card.controller;
|
||||
|
||||
import com.xhpc.card.service.IXhpcCardService;
|
||||
import com.xhpc.common.core.domain.R;
|
||||
import com.xhpc.common.core.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
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 javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author yuyang
|
||||
* @date 2022/1/20 11:33
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/card")
|
||||
@Api(value = "卡管理", tags = "卡管理")
|
||||
public class XhpcCardController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IXhpcCardService xhpcCardService;
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(XhpcCardController.class);
|
||||
|
||||
/**
|
||||
* 卡启动前判断
|
||||
* @param cardno 卡物理卡号
|
||||
* @param serialNumber 终端编号
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/cardStartup")
|
||||
public R cardStartup(@RequestParam(value = "cardno") String cardno, @RequestParam(value = "serialNumber") String serialNumber){
|
||||
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<卡启动充电判断>>>>>>>>>>>>>>>>>");
|
||||
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<卡启动充电判断>>>>>>>>>>>>>>>>>");
|
||||
return xhpcCardService.cardStartup(cardno, serialNumber);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package com.xhpc.card.mapper;
|
||||
|
||||
import com.xhpc.common.domain.IccardInfo;
|
||||
import com.xhpc.common.domain.XhpcIcCardInfo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* @author yuyang
|
||||
* @date 2022/1/20 13:45
|
||||
*/
|
||||
public interface XhpcCardMapper {
|
||||
|
||||
IccardInfo getIccardInfoCardno(@Param("cardno")String cardno);
|
||||
|
||||
XhpcIcCardInfo getXhpcIcCardInfo(@Param("tIccardInfoId")String tIccardInfoId);
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package com.xhpc.card.service;
|
||||
|
||||
import com.xhpc.common.core.domain.R;
|
||||
|
||||
/**
|
||||
* @author yuyang
|
||||
* @date 2022/1/20 13:44
|
||||
*/
|
||||
public interface IXhpcCardService {
|
||||
|
||||
/**
|
||||
* 卡启动充电判断
|
||||
* @param cardno 卡物理卡号
|
||||
* @param serialNumber 终端卡号
|
||||
* @return
|
||||
*/
|
||||
R cardStartup(String cardno,String serialNumber);
|
||||
}
|
||||
@ -0,0 +1,69 @@
|
||||
package com.xhpc.card.service.impl;
|
||||
|
||||
import com.xhpc.card.mapper.XhpcCardMapper;
|
||||
import com.xhpc.card.service.IXhpcCardService;
|
||||
import com.xhpc.common.api.CardHistoryOrderService;
|
||||
import com.xhpc.common.core.constant.Constants;
|
||||
import com.xhpc.common.core.domain.R;
|
||||
import com.xhpc.common.domain.IccardInfo;
|
||||
import com.xhpc.common.domain.XhpcIcCardInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author yuyang
|
||||
* @date 2022/1/20 13:44
|
||||
*/
|
||||
@Service
|
||||
public class XhpcCardServiceImpl implements IXhpcCardService {
|
||||
|
||||
@Autowired
|
||||
private XhpcCardMapper xhpcCardMapper;
|
||||
|
||||
@Autowired
|
||||
private CardHistoryOrderService cardHistoryOrderService;
|
||||
|
||||
|
||||
/**
|
||||
* 卡启动充电判断
|
||||
*
|
||||
* @param cardno
|
||||
* @param serialNumber
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public R cardStartup(String cardno, String serialNumber) {
|
||||
|
||||
IccardInfo iccardInfo = xhpcCardMapper.getIccardInfoCardno(cardno);
|
||||
if(iccardInfo !=null){
|
||||
if(iccardInfo.getCardtype()==0){
|
||||
return R.fail(Constants.OFFLINE_CARD);
|
||||
}
|
||||
if(iccardInfo.getStatus()==0){
|
||||
return R.fail(Constants.ZERO_CARD);
|
||||
}
|
||||
if(iccardInfo.getStatus()==2){
|
||||
return R.fail(Constants.TWO_CARD);
|
||||
}
|
||||
if(iccardInfo.getStatus()==3){
|
||||
return R.fail(Constants.THREE_CARD);
|
||||
}
|
||||
if(iccardInfo.getStatus()==4){
|
||||
return R.fail(Constants.FOUR_CARD);
|
||||
}
|
||||
}else{
|
||||
return R.fail(Constants.LNVALID_CARD);
|
||||
}
|
||||
//查询卡号对应的用户
|
||||
XhpcIcCardInfo xhpcIcCardInfo = xhpcCardMapper.getXhpcIcCardInfo(iccardInfo.getId().toString());
|
||||
if(xhpcIcCardInfo ==null){
|
||||
return R.fail(Constants.LNVALID_USER);
|
||||
}
|
||||
Long userId=xhpcIcCardInfo.getUserId();
|
||||
Integer userType=xhpcIcCardInfo.getUserType();
|
||||
String tenantId=xhpcIcCardInfo.getTenantId();
|
||||
Integer type =1;
|
||||
String grantOperator=xhpcIcCardInfo.getGrantOperatorId();
|
||||
return cardHistoryOrderService.cardStartup(userId, serialNumber, userType,tenantId,type,grantOperator);
|
||||
}
|
||||
}
|
||||
2
xhpc-modules/xhpc-card/src/main/resources/banner.txt
Normal file
2
xhpc-modules/xhpc-card/src/main/resources/banner.txt
Normal file
@ -0,0 +1,2 @@
|
||||
Spring Boot Version: ${spring-boot.version}
|
||||
Spring Application Name: ${spring.application.name}
|
||||
28
xhpc-modules/xhpc-card/src/main/resources/bootstrap.yml
Normal file
28
xhpc-modules/xhpc-card/src/main/resources/bootstrap.yml
Normal file
@ -0,0 +1,28 @@
|
||||
# Tomcat
|
||||
server:
|
||||
port: 9809
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
application:
|
||||
# 应用名称
|
||||
name: xhpc-card
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
logging:
|
||||
level:
|
||||
com.xhpc.card.mapper: debug
|
||||
75
xhpc-modules/xhpc-card/src/main/resources/logback.xml
Normal file
75
xhpc-modules/xhpc-card/src/main/resources/logback.xml
Normal file
@ -0,0 +1,75 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<!-- 日志存放路径 -->
|
||||
<property name="log.path" value="logs/xhpc-card"/>
|
||||
<!-- 日志输出格式 -->
|
||||
<property name="log.pattern"
|
||||
value="%d{MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
||||
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 系统日志输出 -->
|
||||
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/info.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>INFO</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/error.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>ERROR</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!-- 系统模块日志级别控制 -->
|
||||
<logger name="com.xhpc" level="info"/>
|
||||
<!-- Spring日志级别控制 -->
|
||||
<logger name="org.springframework" level="warn"/>
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="console"/>
|
||||
</root>
|
||||
|
||||
<!--系统操作日志-->
|
||||
<root level="info">
|
||||
<appender-ref ref="file_info"/>
|
||||
<appender-ref ref="file_error"/>
|
||||
</root>
|
||||
</configuration>
|
||||
@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.xhpc.card.mapper.XhpcCardMapper">
|
||||
|
||||
<resultMap type="com.xhpc.common.domain.XhpcIcCardInfo" id="XhpcIcCardInfoResult">
|
||||
<result column="ic_card_info_id" property="icCardInfoId"/>
|
||||
<result column="t_iccard_info_id" property="tIccardInfoId"/>
|
||||
<result column="use_status" property="useStatus"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="tenant_id" property="tenantId"/>
|
||||
<result column="grant_operator_id" property="grantOperatorId"/>
|
||||
<result column="user_id" property="userId"/>
|
||||
<result column="user_account" property="userName"/>
|
||||
<result column="user_type" property="userType"/>
|
||||
<result column="user_name" property="userName"/>
|
||||
<result column="user_id_card" property="userIdCard"/>
|
||||
<result column="user_age" property="userAge"/>
|
||||
<result column="user_sex" property="userSex"/>
|
||||
<result column="user_phone" property="userPhone"/>
|
||||
<result column="user_vehicle" property="userVehicle"/>
|
||||
<result column="del_flag" property="delFlag"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
|
||||
<select id="getIccardInfoCardno" resultType="com.xhpc.common.domain.IccardInfo">
|
||||
select * from t_iccard_info where cardNo=#{cardno} order by createTime desc limit 1
|
||||
</select>
|
||||
|
||||
<select id="getXhpcIcCardInfo" resultMap="XhpcIcCardInfoResult">
|
||||
select * from xhpc_ic_card_info where t_iccard_info_id=#{tIccardInfoId} and del_flag=0 order by create_time desc limit 1
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
@ -0,0 +1,29 @@
|
||||
package com.xhpc.common.api;
|
||||
|
||||
import com.xhpc.common.api.factory.CardHistoryOrderFactory;
|
||||
import com.xhpc.common.core.constant.ServiceNameConstants;
|
||||
import com.xhpc.common.core.domain.R;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
* @author yuyang
|
||||
* @date 2022/1/24 17:50
|
||||
*/
|
||||
@FeignClient(contextId ="cardHistoryOrderService",value = ServiceNameConstants.XHPC_ORDER, fallbackFactory = CardHistoryOrderFactory.class)
|
||||
public interface CardHistoryOrderService {
|
||||
|
||||
/**
|
||||
* 卡启动前判断
|
||||
* @param userId 用户id
|
||||
* @param serialNumber 桩号
|
||||
* @param userType 用户类型
|
||||
* @param tenantId 租户
|
||||
* @param type 0 平台 1运营商
|
||||
* @param grantOperator 运营商id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/api/chargeOrder/cardStartup")
|
||||
R cardStartup(@RequestParam(value = "userId") Long userId, @RequestParam(value = "serialNumber") String serialNumber, @RequestParam(value = "userType") Integer userType, @RequestParam(value = "tenantId") String tenantId, @RequestParam(value = "type") Integer type, @RequestParam(value = "grantOperator") String grantOperator);
|
||||
}
|
||||
@ -17,10 +17,10 @@ public interface CardService {
|
||||
|
||||
/**
|
||||
* 卡启动判断接口
|
||||
* @param cardNumber 卡号
|
||||
* @param cardno 卡编号
|
||||
* @param serialNumber 终端编码
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/card/cardStartup")
|
||||
R cardStartup(@RequestParam(value = "cardNumber") String cardNumber, @RequestParam(value = "serialNumber") String serialNumber);
|
||||
R cardStartup(@RequestParam(value = "cardno") String cardno, @RequestParam(value = "serialNumber") String serialNumber);
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@ public class CardFallbackFactory implements FallbackFactory<CardService> {
|
||||
public CardService create(Throwable cause) {
|
||||
return new CardService() {
|
||||
@Override
|
||||
public R cardStartup(String cardNumber, String serialNumber) {
|
||||
public R cardStartup(String cardno, String serialNumber) {
|
||||
return R.fail("卡启动判断接口失败:" + cause.getMessage());
|
||||
}
|
||||
};
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
package com.xhpc.common.api.factory;
|
||||
|
||||
import com.xhpc.common.api.CardHistoryOrderService;
|
||||
import com.xhpc.common.core.domain.R;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author yuyang
|
||||
* @date 2022/1/24 17:51
|
||||
*/
|
||||
@Component
|
||||
public class CardHistoryOrderFactory implements FallbackFactory<CardHistoryOrderService> {
|
||||
@Override
|
||||
public CardHistoryOrderService create(Throwable cause) {
|
||||
|
||||
return new CardHistoryOrderService() {
|
||||
@Override
|
||||
public R cardStartup(Long userId,String serialNumber,Integer userType,String tenantId,Integer type,String grantOperator) {
|
||||
return R.fail("卡启动前判断启动失败:" + cause.getMessage());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
package com.xhpc.common.domain;
|
||||
|
||||
import com.xhpc.common.core.web.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
@ -10,11 +11,11 @@ import java.util.Date;
|
||||
* @author WH
|
||||
*/
|
||||
@Data
|
||||
public class XhpcIcCardInfo implements Serializable {
|
||||
public class XhpcIcCardInfo extends BaseEntity {
|
||||
/**
|
||||
* 记录id
|
||||
*/
|
||||
private Integer id;
|
||||
private Long icCardInfoId;
|
||||
|
||||
/**
|
||||
* t_iccard_info表中的卡记录的id
|
||||
@ -24,7 +25,7 @@ public class XhpcIcCardInfo implements Serializable {
|
||||
/**
|
||||
* 卡使用状态(0未使用,1已绑定)
|
||||
*/
|
||||
private Long useStatus;
|
||||
private Integer useStatus;
|
||||
|
||||
/**
|
||||
* 创建日期
|
||||
@ -44,7 +45,7 @@ public class XhpcIcCardInfo implements Serializable {
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Integer userId;
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 用户账户
|
||||
@ -54,7 +55,7 @@ public class XhpcIcCardInfo implements Serializable {
|
||||
/**
|
||||
* 用户类型(0 C端用户 1 流量方用户 2社区用户 3B端用户)
|
||||
*/
|
||||
private Long userType;
|
||||
private Integer userType;
|
||||
|
||||
/**
|
||||
* 用户姓名
|
||||
@ -69,12 +70,12 @@ public class XhpcIcCardInfo implements Serializable {
|
||||
/**
|
||||
* 用户年龄
|
||||
*/
|
||||
private Long userAge;
|
||||
private Integer userAge;
|
||||
|
||||
/**
|
||||
* 用户性别(0女,1男)
|
||||
*/
|
||||
private Long userSex;
|
||||
private Integer userSex;
|
||||
|
||||
/**
|
||||
* 用户手机号码
|
||||
@ -89,7 +90,5 @@ public class XhpcIcCardInfo implements Serializable {
|
||||
/**
|
||||
* 逻辑删除字段(默认为0,1为删除)
|
||||
*/
|
||||
private Long delFlag;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Integer delFlag;
|
||||
}
|
||||
@ -2,6 +2,7 @@ package com.xhpc.iccard.mapper;
|
||||
|
||||
import com.xhpc.common.domain.IccardInfo;
|
||||
import com.xhpc.common.domain.IccardInfoExample;
|
||||
import com.xhpc.common.domain.XhpcIcCardInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ package com.xhpc.order.api;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xhpc.common.api.WebSocketService;
|
||||
import com.xhpc.common.core.domain.R;
|
||||
import com.xhpc.common.core.web.controller.BaseController;
|
||||
import com.xhpc.common.core.web.domain.AjaxResult;
|
||||
import com.xhpc.common.core.web.page.TableDataInfo;
|
||||
@ -165,4 +166,19 @@ public class XhpcChargeOrderController extends BaseController {
|
||||
webSocketService.getMessage(message,json.toString());
|
||||
logger.info("<<<<<<<<<<发送数据<<<<<<<<<<<<<<"+ json.toString()+">>>>>>>>>>>>>>>>>");
|
||||
}
|
||||
|
||||
/**
|
||||
* 卡启动前判断
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/cardStartup")
|
||||
public R cardStartup(Long userId, String serialNumber, Integer userType, String tenantId, Integer type, String grantOperator)
|
||||
{
|
||||
return iXhpcChargeOrderService.cardStartup(userId,serialNumber,userType,tenantId,type,grantOperator);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -204,7 +204,7 @@ public class XhpcPileOrderController extends BaseController {
|
||||
String tenantId = xhpcChargeOrder.getTenantId();
|
||||
//存入换成
|
||||
JSONObject json = new JSONObject(map);
|
||||
String message = tenantId + UserTypeUtil.USER + userId;
|
||||
String message = "";
|
||||
if(UserTypeUtil.USER_TYPE.equals(source)){
|
||||
message = tenantId + UserTypeUtil.USER + userId;
|
||||
}else if(UserTypeUtil.COMMUNIT_TYPE.equals(source)){
|
||||
|
||||
@ -165,4 +165,8 @@ public interface IXhpcChargeOrderService {
|
||||
|
||||
//获取桩信息
|
||||
Map<String,Object> getXhpcChargingPileById(Long chargingPileId);
|
||||
|
||||
|
||||
R cardStartup(Long userId,String serialNumber,Integer userType,String tenantId, Integer type, String grantOperator);
|
||||
|
||||
}
|
||||
@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUnit;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.xhpc.common.api.PowerPileService;
|
||||
import com.xhpc.common.api.UserTypeService;
|
||||
import com.xhpc.common.core.constant.Constants;
|
||||
import com.xhpc.common.core.domain.R;
|
||||
import com.xhpc.common.core.utils.StringUtils;
|
||||
import com.xhpc.common.core.web.domain.AjaxResult;
|
||||
@ -268,8 +269,6 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar
|
||||
if (r1.getCode() != 200) {
|
||||
return AjaxResult.error(r1.getMsg());
|
||||
}
|
||||
|
||||
|
||||
//创建充电订单(充电启动soc初始值,结束是获取,并修改状态)
|
||||
XhpcChargeOrder xhpcChargeOrder = new XhpcChargeOrder();
|
||||
xhpcChargeOrder.setChargingStationId(xhpcTerminal.getChargingStationId());
|
||||
@ -628,6 +627,88 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar
|
||||
return xhpcChargeOrderMapper.getXhpcChargingPileById(chargingPileId,null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public R cardStartup(Long userId, String serialNumber, Integer userType,String tenantId, Integer type, String grantOperator) {
|
||||
|
||||
R user = userTypeService.getUser(null, userId, userType, null,tenantId);
|
||||
if(user ==null || user.getData() ==null){
|
||||
return R.fail(Constants.LNVALID_USER);
|
||||
}
|
||||
|
||||
Map<String, Object> userMessage = (Map<String, Object>)user.getData();
|
||||
//桩号是否有效
|
||||
String pattern = "^([0-9]{16})";
|
||||
Pattern compile = Pattern.compile(pattern);
|
||||
Matcher m = compile.matcher(serialNumber);
|
||||
if (serialNumber.length() != 16 || !m.matches()) {
|
||||
return R.fail(Constants.LNVALID_TERMINAL);
|
||||
}
|
||||
|
||||
//终端信息
|
||||
XhpcTerminal xhpcTerminal = xhpcChargeOrderMapper.getXhpcTerminalSerialNumber(serialNumber,tenantId);
|
||||
if (xhpcTerminal == null || xhpcTerminal.getTerminalId() == null || xhpcTerminal.getChargingPileId() == null || xhpcTerminal.getPileSerialNumber() == null) {
|
||||
return R.fail(Constants.LNVALID_TERMINAL);
|
||||
}
|
||||
|
||||
if(type !=0){
|
||||
//获取桩信息
|
||||
Map<String, Object> xhpcChargingPileById =xhpcChargeOrderMapper.getXhpcChargingPileById(xhpcTerminal.getChargingPileId(),tenantId);
|
||||
if(xhpcChargingPileById ==null || !xhpcChargingPileById.get("operatorId").toString().equals(grantOperator)){
|
||||
return R.fail(Constants.LNVALID_OPERATOR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BigDecimal a = new BigDecimal(5);
|
||||
if (userMessage == null || userMessage.get("balance") == null || a.compareTo(new BigDecimal(userMessage.get("balance").toString())) == 1) {
|
||||
return R.fail(Constants.INSUFFICIENT_ACCOUNT);
|
||||
}
|
||||
|
||||
//充电用户是否存在异常的订单
|
||||
int j = xhpcChargeOrderMapper.countXhpcChargeOrder(userId,userType,tenantId);
|
||||
if (j > 0) {
|
||||
return R.fail(Constants.EXCEPTION_ORDER);
|
||||
}
|
||||
//查看充电用户是否有申请退款的订单,还未处理
|
||||
if (Integer.parseInt(userMessage.get("isRefundApplication").toString()) != 0) {
|
||||
return R.fail(Constants.REFUND_ORDER);
|
||||
}
|
||||
//充电用户是否在充电中
|
||||
String i = xhpcChargeOrderMapper.countXhpcRealTimeOrder(userId,userType,tenantId);
|
||||
if (!"".equals(i) && i!=null) {
|
||||
return R.fail(Constants.CHARGE_ORDER);
|
||||
}
|
||||
Map<String, Object> cacheMap = REDIS.getCacheMap("gun:" + serialNumber);
|
||||
if(cacheMap==null){
|
||||
return R.fail(Constants.UNREGISTERED_TERMINAL);
|
||||
}else{
|
||||
if(cacheMap.get("status") ==null){
|
||||
return R.fail(Constants.UNKNOWN_TERMINAL);
|
||||
}else{
|
||||
String status = cacheMap.get("status").toString();
|
||||
//不同的状态
|
||||
if("离线".equals(status)){
|
||||
return R.fail(Constants.OFFLINE_TERMINAL);
|
||||
}
|
||||
if("故障".equals(status)){
|
||||
return R.fail(Constants.FAULT_TERMINAL);
|
||||
}
|
||||
if("充电".equals(status)){
|
||||
return R.fail(Constants.CHARGE_TERMINAL);
|
||||
}
|
||||
}
|
||||
if(cacheMap.get("vehicleGunStatus") ==null){
|
||||
return R.fail(Constants.UNKNOWN_GUN);
|
||||
}else{
|
||||
String vehicleGunStatus = cacheMap.get("vehicleGunStatus").toString();
|
||||
if(!"是".equals(vehicleGunStatus)){
|
||||
return R.fail(Constants.INSERT_THE_GUN);
|
||||
}
|
||||
}
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
public static boolean isValidDate(String str) {
|
||||
try {
|
||||
if (0 != str.length()) {
|
||||
|
||||
@ -147,13 +147,12 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
|
||||
@Transactional
|
||||
@Override
|
||||
public AjaxResult getExamineMessage(Long realTimeOrderId) {
|
||||
|
||||
//基本信息
|
||||
Map<String, Object> message = xhpcRealTimeOrderMapper.getMessage(realTimeOrderId);
|
||||
try{
|
||||
if(message ==null || message.get("chargeOrderId") ==null){
|
||||
return AjaxResult.success(new HashMap<>());
|
||||
}
|
||||
|
||||
//获取开始充电时间、结束时间、计费模型、充电度数、已充金额
|
||||
XhpcChargeOrder chargeOrder = xhpcChargeOrderService.getChargingOrderId(Long.parseLong(message.get("chargeOrderId").toString()));
|
||||
|
||||
@ -209,6 +208,11 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
|
||||
//当没有缓存数据时,查询数据库
|
||||
XhpcRealTimeOrder startRealTimeOrder = xhpcRealTimeOrderMapper.getChargingOrderId(chargeOrder.getChargeOrderId(), 1);
|
||||
|
||||
if(startRealTimeOrder ==null){
|
||||
message.put("powerPriceTotal",0);
|
||||
message.put("servicePriceTotal",0);
|
||||
return AjaxResult.success(message);
|
||||
}
|
||||
XhpcRealTimeOrder endRealTimeOrder = xhpcRealTimeOrderMapper.getChargingOrderId(chargeOrder.getChargeOrderId(), 2);
|
||||
|
||||
message.put("soc",endRealTimeOrder.getSoc());
|
||||
@ -221,7 +225,7 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
|
||||
chargeOrder.setChargingTime(endRealTimeOrder.getChargingTime());
|
||||
message.put("chargingTime",endRealTimeOrder.getChargingTime());
|
||||
|
||||
if(chargeOrder.getStartTime().equals(chargeOrder.getEndTime())){
|
||||
if(startRealTimeOrder.getRealTimeOrderId().equals(startRealTimeOrder.getRealTimeOrderId())){
|
||||
message.put("powerPriceTotal",0);
|
||||
message.put("servicePriceTotal",0);
|
||||
return AjaxResult.success(message);
|
||||
@ -281,7 +285,13 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
|
||||
|
||||
//修改充电订单
|
||||
xhpcChargeOrderService.updateXhpcChargeOrder(chargeOrder);
|
||||
|
||||
}catch (Exception e){
|
||||
message.put("powerPriceTotal",0);
|
||||
message.put("servicePriceTotal",0);
|
||||
}
|
||||
return AjaxResult.success(message);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -388,13 +388,15 @@
|
||||
|
||||
<select id="getXhpcChargingPileById" resultType="map">
|
||||
select
|
||||
charging_pile_id as chargingPileId,
|
||||
communication_protocol_version as communicationProtocolVersion,
|
||||
power as power
|
||||
from xhpc_charging_pile
|
||||
where charging_pile_id=#{chargingPileid}
|
||||
cp.charging_pile_id as chargingPileId,
|
||||
cs.operator_id as operatorId,
|
||||
cp.communication_protocol_version as communicationProtocolVersion,
|
||||
cp.power as power
|
||||
from xhpc_charging_pile as cp
|
||||
left join xhpc_charging_station as cs on cs.charging_station_id = cp.charging_station_id
|
||||
where cp.charging_pile_id=#{chargingPileid}
|
||||
<if test="tenantId !=null and tenantId !=''">
|
||||
amd tenant_id=#{tenantId}
|
||||
and cp.tenant_id=#{tenantId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user