Compare commits

...

3 Commits

Author SHA1 Message Date
阿斌
ba3bb1ca06
Pre Merge pull request !41 from 阿斌/N/A 2026-05-20 03:21:38 +00:00
lin
e545b00a8f 部标-tcp空闲超时时间改为可配置 2026-05-20 11:20:56 +08:00
阿斌
34d1dbb399
修复两次密码不一致时,任然可以修改密码,且成功提交,密码用*代替
还有以下一处需要修改web\src\layout\components\dialog\changePassword.vue

Signed-off-by: 阿斌 <38912748@qq.com>
2025-08-23 15:03:02 +00:00
5 changed files with 25 additions and 6 deletions

View File

@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.jt1078.codec.netty;
import com.genersoft.iot.vmp.jt1078.codec.decode.Jt808Decoder; import com.genersoft.iot.vmp.jt1078.codec.decode.Jt808Decoder;
import com.genersoft.iot.vmp.jt1078.codec.encode.Jt808Encoder; import com.genersoft.iot.vmp.jt1078.codec.encode.Jt808Encoder;
import com.genersoft.iot.vmp.jt1078.codec.encode.Jt808EncoderCmd; import com.genersoft.iot.vmp.jt1078.codec.encode.Jt808EncoderCmd;
import com.genersoft.iot.vmp.jt1078.config.JT1078Config;
import com.genersoft.iot.vmp.jt1078.proc.factory.CodecFactory; import com.genersoft.iot.vmp.jt1078.proc.factory.CodecFactory;
import com.genersoft.iot.vmp.jt1078.service.Ijt1078Service; import com.genersoft.iot.vmp.jt1078.service.Ijt1078Service;
import io.netty.bootstrap.ServerBootstrap; import io.netty.bootstrap.ServerBootstrap;
@ -38,13 +39,15 @@ public class TcpServer {
private EventLoopGroup workerGroup = null; private EventLoopGroup workerGroup = null;
private ApplicationEventPublisher applicationEventPublisher = null; private ApplicationEventPublisher applicationEventPublisher = null;
private Ijt1078Service service = null; private Ijt1078Service service = null;
private final JT1078Config jt1078Config;
private final ByteBuf DECODER_JT808 = Unpooled.wrappedBuffer(new byte[]{0x7e}); private final ByteBuf DECODER_JT808 = Unpooled.wrappedBuffer(new byte[]{0x7e});
public TcpServer(Integer port, ApplicationEventPublisher applicationEventPublisher, Ijt1078Service service) { public TcpServer(Integer port, ApplicationEventPublisher applicationEventPublisher, Ijt1078Service service, JT1078Config jt1078Config) {
this.port = port; this.port = port;
this.applicationEventPublisher = applicationEventPublisher; this.applicationEventPublisher = applicationEventPublisher;
this.service = service; this.service = service;
this.jt1078Config = jt1078Config;
} }
private void startTcpServer() { private void startTcpServer() {
@ -63,7 +66,7 @@ public class TcpServer {
@Override @Override
public void initChannel(NioSocketChannel channel) { public void initChannel(NioSocketChannel channel) {
channel.pipeline() channel.pipeline()
.addLast(new IdleStateHandler(10, 0, 0, TimeUnit.MINUTES)) .addLast(new IdleStateHandler(jt1078Config.getReaderIdleTime(), 0, 0, TimeUnit.MINUTES))
.addLast(new DelimiterBasedFrameDecoder(1024 * 2, DECODER_JT808)) .addLast(new DelimiterBasedFrameDecoder(1024 * 2, DECODER_JT808))
.addLast(new Jt808Decoder(applicationEventPublisher, service)) .addLast(new Jt808Decoder(applicationEventPublisher, service))
.addLast(new Jt808Encoder()) .addLast(new Jt808Encoder())

View File

@ -26,8 +26,11 @@ public class JT1078AutoConfiguration {
@Autowired @Autowired
private Ijt1078Service service; private Ijt1078Service service;
@Autowired
private JT1078Config jt1078Config;
@Bean(initMethod = "start", destroyMethod = "stop") @Bean(initMethod = "start", destroyMethod = "stop")
public TcpServer jt1078Server(@Value("${jt1078.port}") Integer port) { public TcpServer jt1078Server(@Value("${jt1078.port}") Integer port) {
return new TcpServer(port, applicationEventPublisher, service); return new TcpServer(port, applicationEventPublisher, service, jt1078Config);
} }
} }

View File

@ -17,4 +17,9 @@ public class JT1078Config {
private String password; private String password;
private Boolean record = false; private Boolean record = false;
/**
* IdleStateHandler reader idle timeout, unit: minutes
*/
private Integer readerIdleTime = 15;
} }

View File

@ -20,7 +20,7 @@ public class JT1078ServerTest {
public static void main(String[] args) { public static void main(String[] args) {
System.out.println("Starting jt1078 server..."); System.out.println("Starting jt1078 server...");
TcpServer tcpServer = new TcpServer(21078, null, null); TcpServer tcpServer = new TcpServer(21078, null, null, null);
tcpServer.start(); tcpServer.start();
System.out.println("Start jt1078 server success!"); System.out.println("Start jt1078 server success!");

View File

@ -13,10 +13,10 @@
<div id="shared" style="margin-right: 20px;"> <div id="shared" style="margin-right: 20px;">
<el-form ref="passwordForm" :rules="rules" status-icon label-width="80px"> <el-form ref="passwordForm" :rules="rules" status-icon label-width="80px">
<el-form-item label="新密码" prop="newPassword"> <el-form-item label="新密码" prop="newPassword">
<el-input v-model="newPassword" autocomplete="off" /> <el-input v-model="newPassword" autocomplete="off" type="password" />
</el-form-item> </el-form-item>
<el-form-item label="确认密码" prop="confirmPassword"> <el-form-item label="确认密码" prop="confirmPassword">
<el-input v-model="confirmPassword" autocomplete="off" /> <el-input v-model="confirmPassword" autocomplete="off" type="password" />
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
@ -88,6 +88,14 @@ export default {
} }
}, },
onSubmit: function() { onSubmit: function() {
if (this.newPassword !== this.confirmPassword) {
this.$message({
showClose: true,
message: '两次输入密码不一致!',
type: 'error'
})
return
}
this.$store.dispatch('user/changePasswordForAdmin', { this.$store.dispatch('user/changePasswordForAdmin', {
password: this.newPassword, password: this.newPassword,
userId: this.form.id userId: this.form.id