* !44 comment
* !39 添加下行日志打印
* !36 扩展计价领域模型
* !35 webui 初步成型
* !34 webui 初步成型
This commit is contained in:
三丙
2025-09-09 08:23:59 +00:00
parent 921045af8f
commit 58580ca11e
372 changed files with 37900 additions and 1206 deletions

View File

@@ -45,24 +45,6 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<skip>false</skip>
<layout>ZIP</layout>
<mainClass>sanbing.jcpp.protocol.JCPPProtocolServiceApplication</mainClass>
<excludeDevtools>true</excludeDevtools>
<layers>
<enabled>true</enabled>
<configuration>${project.basedir}/src/layers.xml</configuration>
</layers>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>

View File

@@ -1,35 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
开源代码,仅供学习和交流研究使用,商用请联系三丙
微信mohan_88888
抖音:程序员三丙
付费课程知识星球https://t.zsxq.com/aKtXo
-->
<layers xmlns="http://www.springframework.org/schema/boot/layers"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/boot/layers
https://www.springframework.org/schema/boot/layers/layers-2.7.xsd">
<application>
<into layer="spring-boot-loader">
<include>org/springframework/boot/loader/**</include>
</into>
<into layer="application" />
</application>
<dependencies>
<into layer="application">
<includeModuleDependencies />
</into>
<into layer="snapshot-dependencies">
<include>*:*:*SNAPSHOT</include>
</into>
<into layer="dependencies" />
</dependencies>
<layerOrder>
<layer>dependencies</layer>
<layer>spring-boot-loader</layer>
<layer>snapshot-dependencies</layer>
<layer>application</layer>
</layerOrder>
</layers>

View File

@@ -6,16 +6,20 @@
*/
package sanbing.jcpp.protocol;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.Banner;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.core.Ordered;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import sanbing.jcpp.infrastructure.util.annotation.AfterStartUp;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
/**
* @author baigod
* @author 九筒
*/
@SpringBootApplication(scanBasePackages = {"sanbing.jcpp.protocol",
"sanbing.jcpp.infrastructure.stats",
@@ -23,12 +27,16 @@ import java.util.Arrays;
"sanbing.jcpp.infrastructure.util"})
@EnableAsync
@EnableScheduling
@Slf4j
public class JCPPProtocolServiceApplication {
private static final String SPRING_CONFIG_NAME_KEY = "--spring.config.name";
private static final String DEFAULT_SPRING_CONFIG_PARAM = SPRING_CONFIG_NAME_KEY + "=" + "protocol-service";
private static long startTs;
public static void main(String[] args) {
startTs = System.currentTimeMillis();
new SpringApplicationBuilder(JCPPProtocolServiceApplication.class).bannerMode(Banner.Mode.LOG).run(updateArguments(args));
}
@@ -41,4 +49,11 @@ public class JCPPProtocolServiceApplication {
}
return args;
}
@AfterStartUp(order = Ordered.LOWEST_PRECEDENCE)
public void afterStartUp() {
long startupTimeMs = System.currentTimeMillis() - startTs;
log.info("Started JChargePointProtocol Protocol Service in {} seconds", TimeUnit.MILLISECONDS.toSeconds(startupTimeMs));
}
}

View File

@@ -1,4 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
开源代码,仅供学习和交流研究使用,商用请联系三丙
微信mohan_88888
抖音:程序员三丙
付费课程知识星球https://t.zsxq.com/aKtXo
-->
<configuration status="INFO" monitorInterval="30">
<properties>

View File

@@ -6,19 +6,18 @@
*/
package sanbing.jcpp.protocol;
import jakarta.annotation.Resource;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.TestMethodOrder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.core.env.Environment;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.web.servlet.MockMvc;
/**
* @author baigod
* @author 九筒
*/
@ActiveProfiles("test")
@SpringBootTest(classes = JCPPProtocolServiceApplication.class, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
@@ -33,9 +32,7 @@ public class AbstractProtocolTestBase {
protected final Logger log = LoggerFactory.getLogger(this.getClass());
@Autowired
@Resource
protected MockMvc mockMvc;
@Autowired
protected Environment environment;
}

View File

@@ -22,8 +22,8 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import sanbing.jcpp.infrastructure.util.jackson.JacksonUtil;
import sanbing.jcpp.infrastructure.util.property.PropertyUtils;
import sanbing.jcpp.proto.gen.ProtocolProto;
import sanbing.jcpp.proto.gen.ProtocolProto.DownlinkRequestMessage;
import sanbing.jcpp.proto.gen.ProtocolProto.RemoteStartChargingRequest;
import sanbing.jcpp.protocol.AbstractProtocolTestBase;
import sanbing.jcpp.protocol.domain.DownlinkCmdEnum;
import sanbing.jcpp.protocol.domain.ProtocolSession;
@@ -61,12 +61,7 @@ class DownlinkControllerIT extends AbstractProtocolTestBase {
BinaryHandlerConfiguration binaryHandlerConfig = JacksonUtil.treeToValue(cfgJson, BinaryHandlerConfiguration.class);
ByteOrder byteOrder = LITTLE_ENDIAN_BYTE_ORDER.equalsIgnoreCase(binaryHandlerConfig.getByteOrder())
? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN;
JCPPLengthFieldBasedFrameDecoder framer = new JCPPLengthFieldBasedFrameDecoder(binaryHandlerConfig.getHead(), byteOrder,
binaryHandlerConfig.getLengthFieldOffset(), binaryHandlerConfig.getLengthFieldLength(),
binaryHandlerConfig.getLengthAdjustment(), binaryHandlerConfig.getInitialBytesToStrip());
JCPPLengthFieldBasedFrameDecoder framer = getJcppLengthFieldBasedFrameDecoder(binaryHandlerConfig);
group = new NioEventLoopGroup();
Bootstrap b = new Bootstrap();
@@ -92,6 +87,15 @@ class DownlinkControllerIT extends AbstractProtocolTestBase {
channel = f.channel();
}
private static JCPPLengthFieldBasedFrameDecoder getJcppLengthFieldBasedFrameDecoder(BinaryHandlerConfiguration binaryHandlerConfig) {
ByteOrder byteOrder = LITTLE_ENDIAN_BYTE_ORDER.equalsIgnoreCase(binaryHandlerConfig.getByteOrder())
? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN;
return new JCPPLengthFieldBasedFrameDecoder(binaryHandlerConfig.getHead(), byteOrder,
binaryHandlerConfig.getLengthFieldOffset(), binaryHandlerConfig.getLengthFieldLength(),
binaryHandlerConfig.getLengthAdjustment(), binaryHandlerConfig.getInitialBytesToStrip());
}
@AfterEach
void tearDown() {
if (channel != null) {
@@ -130,7 +134,7 @@ class DownlinkControllerIT extends AbstractProtocolTestBase {
.setRequestIdMSB(requestId.getMostSignificantBits())
.setRequestIdLSB(requestId.getLeastSignificantBits())
.setDownlinkCmd(DownlinkCmdEnum.REMOTE_START_CHARGING.name())
.setRemoteStartChargingRequest(ProtocolProto.RemoteStartChargingRequest.newBuilder()
.setRemoteStartChargingRequest(RemoteStartChargingRequest.newBuilder()
.setPileCode(pileCode)
.setGunCode("01")
.setLimitYuan("100")