diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/CommonController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/CommonController.java index ae9f246..c826119 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/CommonController.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/CommonController.java @@ -1,12 +1,13 @@ package com.chaozhanggui.system.cashierservice.controller; -import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSONObject; import com.chaozhanggui.system.cashierservice.dao.TbPlatformDictMapper; import com.chaozhanggui.system.cashierservice.dao.TbShopExtendMapper; import com.chaozhanggui.system.cashierservice.entity.TbPlatformDict; import com.chaozhanggui.system.cashierservice.entity.dto.WxMsgSubDTO; import com.chaozhanggui.system.cashierservice.entity.vo.DistrictVo; import com.chaozhanggui.system.cashierservice.exception.MsgException; +import com.chaozhanggui.system.cashierservice.netty.PushToClientChannelHandlerAdapter; import com.chaozhanggui.system.cashierservice.redis.RedisCst; import com.chaozhanggui.system.cashierservice.redis.RedisUtil; import com.chaozhanggui.system.cashierservice.service.FileService; @@ -174,6 +175,15 @@ public class CommonController { return new Result(CodeEnum.SUCCESS, extendMapper.queryByShopIdAndAutoKey(Integer.valueOf(map.get("shopId").toString()),map.get("autokey"))); } + /** + * 交班 + */ + @PostMapping("common/handoverData") + public Result handoverData(@RequestBody Map map) throws Exception{ + PushToClientChannelHandlerAdapter.getInstance().AppSendInfo(JSONObject.toJSONString(map),map.get("shopId")); + return Result.success(CodeEnum.SUCCESS); + } + // 检查手机号格式是否正确的方法 private boolean isValidPhoneNumber(String phone) { return phone.matches("^1[3-9]\\d{9}$"); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/interceptor/CustomFilter.java b/src/main/java/com/chaozhanggui/system/cashierservice/interceptor/CustomFilter.java index b79a877..5e8bb65 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/interceptor/CustomFilter.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/interceptor/CustomFilter.java @@ -14,7 +14,11 @@ import java.util.List; @WebFilter(urlPatterns = {"/cashierService/*"},filterName = "customFilter") public class CustomFilter implements Filter { - private static final List unFilterUrlList= Arrays.asList("/cashierService/notify/notifyCallBack","/cashierService/notify/memberInCallBack"); + private static final List unFilterUrlList = + Arrays.asList( + "/cashierService/notify/notifyCallBack", + "/cashierService/notify/memberInCallBack" + ); private boolean isfilter(String url){ diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/netty/PushToClientChannelHandlerAdapter.java b/src/main/java/com/chaozhanggui/system/cashierservice/netty/PushToClientChannelHandlerAdapter.java index cedc930..b994d1a 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/netty/PushToClientChannelHandlerAdapter.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/netty/PushToClientChannelHandlerAdapter.java @@ -160,6 +160,19 @@ public class PushToClientChannelHandlerAdapter extends NettyChannelHandlerAdapte }); } + @Async + public void AppSendInfo(String message, String shopId) { + log.info("长链接发送交班数据。"); + ConcurrentHashMap webSockets = webSocketMap.get(shopId); + if (webSockets != null) { + for (ChannelHandlerContext ctx : webSockets.values()) { + sendMesToApp(message, ctx); + } + } + } + + + //发送打印消息 有重发机制 public void AppSendInfoV1(String shopId, String orderNo, JSONObject message) { log.info("netty连接client 发送消息 shopId:{} clientId:{} userFlag:{} message:{}", shopId, message.get("orderInfo")); retryQueue.computeIfAbsent(shopId, k -> new ConcurrentLinkedQueue<>()).offer(message); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java index f96fb6c..e0bc950 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java @@ -391,9 +391,6 @@ public class ProductService { if (!CollectionUtils.isEmpty(products)) { products.parallelStream().forEach(it -> { TbShopUnit tbShopUnit = unitMapper.selectByPrimaryKey(Integer.valueOf(it.getUnitId())); - if (it.getName().equals("烤牛肉")) { - System.out.println("单位:"+tbShopUnit.getName()); - } it.setUnitSnap(tbShopUnit != null ? tbShopUnit.getName() : ""); if(check){ List tbProductGroups = tbProductGroupMapper.selectByProductId(it.getShopId(), it.getId().toString());