解决餐饮预约核销成功之后,前端通过websocket没有收到消息的问题

master
bmpandlcm 11 months ago
parent 6c42ab9656
commit f2c4fc89c4

@ -9,14 +9,13 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="29bcb86b-1634-41e0-a498-79481163cba8" name="Changes" comment="附件上传接口修改">
<list default="true" id="29bcb86b-1634-41e0-a498-79481163cba8" name="Changes" comment="附件上传,按照日期存放">
<change afterPath="$PROJECT_DIR$/src/main/java/com/nmgs/controller/LoginController.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/nmgs/controller/FileController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/nmgs/controller/FileController.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/nmgs/controller/FileUploadController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/nmgs/controller/FileUploadController.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/nmgs/service/impl/UserTableServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/nmgs/service/impl/UserTableServiceImpl.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/nmgs/service/impl/UserVehicleServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/nmgs/service/impl/UserVehicleServiceImpl.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/nmgs/util/ImageUtils.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/nmgs/util/ImageUtils.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/nmgs/util/PubTools.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/nmgs/util/PubTools.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/nmgs/controller/WebSocket.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/nmgs/controller/WebSocket.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/nmgs/service/impl/QCodeInfoServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/nmgs/service/impl/QCodeInfoServiceImpl.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/nmgs/util/WebsocketUtil.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/nmgs/util/WebsocketUtil.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -73,58 +72,58 @@
<component name="ProjectViewState">
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;Application.DivPassDataImpl.executor&quot;: &quot;Run&quot;,
&quot;Application.ImageUtils.executor&quot;: &quot;Run&quot;,
&quot;Application.PubTools.executor&quot;: &quot;Run&quot;,
&quot;Application.QCodeInfoServiceImpl.executor&quot;: &quot;Debug&quot;,
&quot;Application.SensitiveFilter.executor&quot;: &quot;Run&quot;,
&quot;Application.main.executor&quot;: &quot;Debug&quot;,
&quot;Application.redisConfigUtil.executor&quot;: &quot;Debug&quot;,
&quot;Maven.IntegraManager [clean].executor&quot;: &quot;Run&quot;,
&quot;Maven.IntegraManager [install].executor&quot;: &quot;Run&quot;,
&quot;Maven.IntegralManager [clean].executor&quot;: &quot;Run&quot;,
&quot;Maven.IntegralManager [install].executor&quot;: &quot;Run&quot;,
&quot;Maven.IntegralManager [validate].executor&quot;: &quot;Run&quot;,
&quot;Maven.IntegralManagerSys [clean].executor&quot;: &quot;Run&quot;,
&quot;Maven.IntegralManagerSys [install].executor&quot;: &quot;Run&quot;,
&quot;Maven.devProject [clean].executor&quot;: &quot;Run&quot;,
&quot;Maven.devProject [install].executor&quot;: &quot;Run&quot;,
&quot;Maven.dev_project [clean].executor&quot;: &quot;Run&quot;,
&quot;Maven.dev_project [install].executor&quot;: &quot;Run&quot;,
&quot;Maven.special_event [clean].executor&quot;: &quot;Run&quot;,
&quot;Maven.special_event [install].executor&quot;: &quot;Run&quot;,
&quot;Maven.special_event [org.apache.maven.plugins:maven-assembly-plugin:3.3.0:single].executor&quot;: &quot;Run&quot;,
&quot;Maven.special_event [org.springframework.boot:spring-boot-maven-plugin:2.7.11:repackage].executor&quot;: &quot;Run&quot;,
&quot;Maven.special_event [package].executor&quot;: &quot;Run&quot;,
&quot;Maven.special_event [validate].executor&quot;: &quot;Run&quot;,
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;,
&quot;TomEE Server.special_event.executor&quot;: &quot;Debug&quot;,
&quot;Tomcat Server.Tomcat 9.0.80.executor&quot;: &quot;Debug&quot;,
&quot;deletionFromPopupRequiresConfirmation&quot;: &quot;false&quot;,
&quot;git-widget-placeholder&quot;: &quot;master&quot;,
&quot;kotlin-language-version-configured&quot;: &quot;true&quot;,
&quot;last_opened_file_path&quot;: &quot;E:/work/TGGLT-WorkSpace/IntegralManager&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
&quot;project.structure.last.edited&quot;: &quot;Modules&quot;,
&quot;project.structure.proportion&quot;: &quot;0.15&quot;,
&quot;project.structure.side.proportion&quot;: &quot;0.37169158&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;vcs.Git&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"Application.DivPassDataImpl.executor": "Run",
"Application.ImageUtils.executor": "Run",
"Application.PubTools.executor": "Run",
"Application.QCodeInfoServiceImpl.executor": "Debug",
"Application.SensitiveFilter.executor": "Run",
"Application.main.executor": "Debug",
"Application.redisConfigUtil.executor": "Debug",
"Maven.IntegraManager [clean].executor": "Run",
"Maven.IntegraManager [install].executor": "Run",
"Maven.IntegralManager [clean].executor": "Run",
"Maven.IntegralManager [install].executor": "Run",
"Maven.IntegralManager [validate].executor": "Run",
"Maven.IntegralManagerSys [clean].executor": "Run",
"Maven.IntegralManagerSys [install].executor": "Run",
"Maven.devProject [clean].executor": "Run",
"Maven.devProject [install].executor": "Run",
"Maven.dev_project [clean].executor": "Run",
"Maven.dev_project [install].executor": "Run",
"Maven.special_event [clean].executor": "Run",
"Maven.special_event [install].executor": "Run",
"Maven.special_event [org.apache.maven.plugins:maven-assembly-plugin:3.3.0:single].executor": "Run",
"Maven.special_event [org.springframework.boot:spring-boot-maven-plugin:2.7.11:repackage].executor": "Run",
"Maven.special_event [package].executor": "Run",
"Maven.special_event [validate].executor": "Run",
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
"TomEE Server.special_event.executor": "Debug",
"Tomcat Server.Tomcat 9.0.80.executor": "Debug",
"deletionFromPopupRequiresConfirmation": "false",
"git-widget-placeholder": "master",
"kotlin-language-version-configured": "true",
"last_opened_file_path": "E:/work/TGGLT-WorkSpace/IntegralManager",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "npm",
"project.structure.last.edited": "Modules",
"project.structure.proportion": "0.15",
"project.structure.side.proportion": "0.37169158",
"settings.editor.selected.configurable": "vcs.Git",
"vue.rearranger.settings.migration": "true"
},
&quot;keyToStringList&quot;: {
&quot;DatabaseDriversLRU&quot;: [
&quot;oracle&quot;
"keyToStringList": {
"DatabaseDriversLRU": [
"oracle"
]
}
}</component>
}]]></component>
<component name="ReactorSettings">
<option name="notificationShown" value="true" />
</component>
@ -147,33 +146,7 @@
<recent name="com.nmgs.entity" />
</key>
</component>
<component name="RunManager" selected="Application.PubTools">
<configuration name="PubTools" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="com.nmgs.util.PubTools" />
<module name="IntegralManager" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="com.nmgs.util.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="SensitiveFilter" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="com.nmgs.util.SensitiveFilter" />
<module name="IntegralManager" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="com.nmgs.util.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<component name="RunManager">
<configuration default="true" type="JetRunConfigurationType">
<module name="IntegraManager" />
<method v="2">
@ -385,17 +358,6 @@
<option name="Make" enabled="true" />
</method>
</configuration>
<list>
<item itemvalue="Application.PubTools" />
<item itemvalue="Application.SensitiveFilter" />
<item itemvalue="Tomcat Server.Tomcat 9.0.80" />
</list>
<recent_temporary>
<list>
<item itemvalue="Application.PubTools" />
<item itemvalue="Application.SensitiveFilter" />
</list>
</recent_temporary>
</component>
<component name="SharedIndexes">
<attachedChunks>
@ -556,7 +518,16 @@
<workItem from="1732673911947" duration="54000" />
<workItem from="1732764840073" duration="622000" />
<workItem from="1732842648636" duration="6217000" />
<workItem from="1732867224102" duration="1353000" />
<workItem from="1732867224102" duration="3134000" />
<workItem from="1733098109747" duration="860000" />
<workItem from="1733190162894" duration="17545000" />
<workItem from="1733386308578" duration="1087000" />
<workItem from="1733457038197" duration="4723000" />
<workItem from="1733703790332" duration="83000" />
<workItem from="1733884773221" duration="2380000" />
<workItem from="1733902595732" duration="639000" />
<workItem from="1733964297677" duration="4644000" />
<workItem from="1733994734948" duration="5074000" />
</task>
<task id="LOCAL-00001" summary="特请处理">
<option name="closed" value="true" />
@ -686,7 +657,31 @@
<option name="project" value="LOCAL" />
<updated>1731986350521</updated>
</task>
<option name="localTasksCounter" value="17" />
<task id="LOCAL-00017" summary="附件上传,按照日期存放">
<option name="closed" value="true" />
<created>1732871610553</created>
<option name="number" value="00017" />
<option name="presentableId" value="LOCAL-00017" />
<option name="project" value="LOCAL" />
<updated>1732871610553</updated>
</task>
<task id="LOCAL-00018" summary="附件上传,按照日期存放">
<option name="closed" value="true" />
<created>1733208152671</created>
<option name="number" value="00018" />
<option name="presentableId" value="LOCAL-00018" />
<option name="project" value="LOCAL" />
<updated>1733208152672</updated>
</task>
<task id="LOCAL-00019" summary="附件上传,按照日期存放">
<option name="closed" value="true" />
<created>1733293115770</created>
<option name="number" value="00019" />
<option name="presentableId" value="LOCAL-00019" />
<option name="project" value="LOCAL" />
<updated>1733293115770</updated>
</task>
<option name="localTasksCounter" value="20" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@ -716,7 +711,8 @@
<MESSAGE value="给后端服务提供的websocket进行消息内容修改" />
<MESSAGE value="新增附件上传接口" />
<MESSAGE value="附件上传接口修改" />
<option name="LAST_COMMIT_MESSAGE" value="附件上传接口修改" />
<MESSAGE value="附件上传,按照日期存放" />
<option name="LAST_COMMIT_MESSAGE" value="附件上传,按照日期存放" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>

@ -21,6 +21,7 @@
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
@ -196,7 +197,12 @@
<artifactId>knife4j-openapi2-spring-boot-starter</artifactId>
<version>4.4.0</version>
</dependency>
<!--springboot redis 配置 -->
<!--实现session共享-->
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
@ -218,7 +224,6 @@
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
<build>

@ -0,0 +1,64 @@
package com.nmgs.controller;
import cn.hutool.captcha.LineCaptcha;
import cn.hutool.captcha.generator.RandomGenerator;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.imageio.ImageIO;
import java.awt.*;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@RestController
@RequestMapping(value = "login")
@Api(tags = "登录信息")
public class LoginController {
/**
*
*
* @return
*/
@RequestMapping(value = "getCode",
method = {RequestMethod.POST}
)
@ApiOperation(httpMethod = "POST", value = "登录页面获取图片流验证码")
public ResponseEntity<byte[]> getCode() throws IOException {
//配置验证码图片的宽度以及验证码字符的个数还有它的模糊程度也就是干扰线这儿设置4个字符1条干扰线
LineCaptcha captcha = new LineCaptcha(130, 40, 4, 1);
//配置只有纯数字 1到9
captcha.setGenerator(new RandomGenerator("123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", 4));
//配置背景颜色
captcha.setBackground(Color.pink);
//配置字体
captcha.setFont(new Font("微软雅黑", Font.BOLD, 18));
//这儿就是生成验证码了
String captchaCode = captcha.getCode();
//其实,到这儿,验证码已配置完成,大家可以打印下 captchaCode 是可以出来4个字符的字符串的。
System.out.println("验证码==========>" + captchaCode);
//下面两行是生成图片的文件流
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ImageIO.write(captcha.getImage(), "png", outputStream);
//在这中间还有一串的代码
//那就是还需要生成唯一的uuid将来需要结合当前生成验证码结合起来
//把它们存到缓存中,这样,前端发送过后就可以拿来做比较
//这儿就是设置返回体以及返回的内容(最后返回的是一个图片的文件流,直接在浏览器访问看到是一个图片)
HttpHeaders headers = new HttpHeaders();
headers.setContentType(org.springframework.http.MediaType.IMAGE_PNG);
headers.set("Cache-Control", "no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
headers.setPragma("no-cache");
headers.setDate("Expires", 0);
byte[] b = outputStream.toByteArray();
return new ResponseEntity<>(b, headers, HttpStatus.OK);
}
}

@ -26,7 +26,7 @@ public class WebSocket {
@OnOpen
public void onOpen(Session session,@PathParam(value = "userId") String userId) throws IOException {
System.out.println("连接websocket的人员======"+userId);
LogUtil.WriteLog_Info("连接websocket的人员======" + userId, "WebSocket");
WebsocketUtil.addSession(userId, session);
JSONObject retJo=new JSONObject();
retJo.put("code",1);
@ -37,7 +37,7 @@ public class WebSocket {
@OnClose
public void onClose(Session session,@PathParam(value = "userId") String userId) {
System.out.println("关闭连接的人员======"+userId);
LogUtil.WriteLog_Info("关闭连接的人员======" + userId, "WebSocket");
String socketId = userId;
WebsocketUtil.removeSession(socketId);
}

@ -1642,12 +1642,13 @@ public class QCodeInfoServiceImpl {
}else{
if (!content.contains("|")) {
//需要判断是否是餐饮预约
String appointMentSql = "select t.ID,t.SERVICEOPERATIONID,tt.JOBNUMBER,t.COMPLETESTATUS from APPOINTMENT_INFO_TABLE t,SERVICE_AREA_OPERATORS_TABLE tt where t.SERVICEOPERATIONID = tt.ID AND t.ORDERID='" + content + "'";
String appointMentSql = "select t.ID,t.SERVICEOPERATIONID,tt.JOBNUMBER,t.COMPLETESTATUS,wut.OPENID from APPOINTMENT_INFO_TABLE t,SERVICE_AREA_OPERATORS_TABLE tt,WEIXN_USER_TABLE wut where wut.ID=t.USERID AND t.SERVICEOPERATIONID = tt.ID AND t.ORDERID='" + content + "'";
List appointMentList = this.mapperI.selectforlist(appointMentSql);
if (appointMentList != null && appointMentList.size() > 0) {
Map<String, Object> appointment = (Map<String, Object>) appointMentList.get(0);
String appomintJob = appointment.get("JOBNUMBER").toString();
String completeStatus = appointment.get("COMPLETESTATUS").toString();
openId = appointment.get("OPENID").toString();
if ("Y".equals(completeStatus)) {
if (!appomintJob.equals(serverOperationId)) {//数据已核销
ret = "12";
@ -1674,6 +1675,7 @@ public class QCodeInfoServiceImpl {
this.mapperI.update(updateAppointSql);
LogUtil.WriteLog_Info("积分核减=====修改预约记录为已核销", "QCodeInfoServiceImpl");
ret = "1";
retJo.put("openId", openId);
retJo.put("ret", ret);
return retJo;
}

@ -62,9 +62,11 @@ public class WebsocketUtil {
*/
public static void sendMessage(Session session, String message) {
if (session == null) {
LogUtil.WriteLog_Info("websocket给前端发送消息======session为空{}" + message, "WebSocket");
return;
}
synchronized(session) {
LogUtil.WriteLog_Info("websocket给前端发送消息======" + session.getId() + "=={}" + message, "WebSocket");
try {
session.getBasicRemote().sendText(message);
} catch (IOException e) {

Loading…
Cancel
Save