Browse Source

一卡通数据双向同步本地程序

baiyun 1 năm trước cách đây
mục cha
commit
5e1aa02408
26 tập tin đã thay đổi với 795 bổ sung32 xóa
  1. 9 0
      ruoyi-api/ruoyi-api-backstage/src/main/java/org/dromara/backstage/api/RemoteMealTypeService.java
  2. 7 0
      ruoyi-api/ruoyi-api-backstage/src/main/java/org/dromara/backstage/api/RemotePtAreaService.java
  3. 11 0
      ruoyi-api/ruoyi-api-backstage/src/main/java/org/dromara/backstage/api/RemotePtParameterService.java
  4. 20 0
      ruoyi-api/ruoyi-api-backstage/src/main/java/org/dromara/backstage/api/RemotePtRoomService.java
  5. 49 0
      ruoyi-api/ruoyi-api-backstage/src/main/java/org/dromara/backstage/api/domain/bo/RemotePtMealTypeBo.java
  6. 58 0
      ruoyi-api/ruoyi-api-backstage/src/main/java/org/dromara/backstage/api/domain/bo/RemotePtParameterBo.java
  7. 37 0
      ruoyi-api/ruoyi-api-backstage/src/main/java/org/dromara/backstage/api/domain/bo/RemotePtRoomBatchSetBo.java
  8. 75 0
      ruoyi-api/ruoyi-api-backstage/src/main/java/org/dromara/backstage/api/domain/bo/RemotePtRoomBo.java
  9. 16 0
      ruoyi-common/ruoyi-common-message/src/main/java/org/dromara/common/message/kafka/constant/MessageEventTypeConstants.java
  10. 22 1
      ruoyi-modules/ruoyi-backstage/src/main/java/org/dromara/backstage/basics/dubbo/RemoteMealTypeServiceImpl.java
  11. 14 4
      ruoyi-modules/ruoyi-backstage/src/main/java/org/dromara/backstage/basics/dubbo/RemotePtAreaServiceImpl.java
  12. 22 0
      ruoyi-modules/ruoyi-backstage/src/main/java/org/dromara/backstage/basics/dubbo/RemotePtParameterServiceImpl.java
  13. 45 0
      ruoyi-modules/ruoyi-backstage/src/main/java/org/dromara/backstage/basics/dubbo/RemotePtRoomServiceImpl.java
  14. 12 0
      ruoyi-server/ruoyi-server-base/pom.xml
  15. 61 0
      ruoyi-server/ruoyi-server-base/src/main/java/org/dromara/server/base/service/yktOperation/SyncRemotePtAreaService.java
  16. 60 0
      ruoyi-server/ruoyi-server-base/src/main/java/org/dromara/server/base/service/yktOperation/SyncRemotePtMealTypeService.java
  17. 41 1
      ruoyi-server/ruoyi-server-base/src/main/java/org/dromara/server/base/service/yktOperation/SyncRemotePtParameterService.java
  18. 66 0
      ruoyi-server/ruoyi-server-base/src/main/java/org/dromara/server/base/service/yktOperation/SyncRemotePtRoomService.java
  19. 3 0
      ruoyi-server/ruoyi-server-base/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
  20. 19 11
      ruoyi-server/ruoyi-server-mqdata/src/main/java/org/dromara/server/mq/consumer/KafkaConsumer.java
  21. 1 1
      ruoyi-server/ruoyi-server-mqdata/src/main/java/org/dromara/server/mq/event/kafka/IYktEventStrategy.java
  22. 2 3
      ruoyi-server/ruoyi-server-mqdata/src/main/java/org/dromara/server/mq/event/kafka/YktEventStrategyContext.java
  23. 44 0
      ruoyi-server/ruoyi-server-mqdata/src/main/java/org/dromara/server/mq/event/kafka/impl/yktOperation/PtAreaEventStrategyImpl.java
  24. 43 0
      ruoyi-server/ruoyi-server-mqdata/src/main/java/org/dromara/server/mq/event/kafka/impl/yktOperation/PtMealTypeEventStrategyImpl.java
  25. 10 11
      ruoyi-server/ruoyi-server-mqdata/src/main/java/org/dromara/server/mq/event/kafka/impl/yktOperation/PtParameterEventStrategyImpl.java
  26. 48 0
      ruoyi-server/ruoyi-server-mqdata/src/main/java/org/dromara/server/mq/event/kafka/impl/yktOperation/PtRoomEventStrategyImpl.java

+ 9 - 0
ruoyi-api/ruoyi-api-backstage/src/main/java/org/dromara/backstage/api/RemoteMealTypeService.java

@@ -1,6 +1,10 @@
 package org.dromara.backstage.api;
 
 import org.dromara.backstage.api.domain.bo.RemotePtAreaBo;
+import org.dromara.backstage.api.domain.bo.RemotePtMealTypeBo;
+import org.dromara.backstage.api.domain.bo.RemotePtParameterBo;
+
+import java.util.Collection;
 
 /**
  * 餐类服务
@@ -11,5 +15,10 @@ public interface RemoteMealTypeService {
 
     String selectMealTypeNameByIds(String ids);
 
+    Boolean insertByBo(RemotePtMealTypeBo bo) throws Exception;
+
+    Boolean updateByBo(RemotePtMealTypeBo bo) throws Exception;
+
+    Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) throws Exception;
 
 }

+ 7 - 0
ruoyi-api/ruoyi-api-backstage/src/main/java/org/dromara/backstage/api/RemotePtAreaService.java

@@ -1,6 +1,9 @@
 package org.dromara.backstage.api;
 
 import org.dromara.backstage.api.domain.bo.RemotePtAreaBo;
+import org.dromara.backstage.api.domain.bo.RemotePtMealTypeBo;
+
+import java.util.Collection;
 
 /**
  * 用户服务
@@ -16,4 +19,8 @@ public interface RemotePtAreaService {
      */
     Boolean insertByBo(RemotePtAreaBo bo);
 
+    Boolean updateByBo(RemotePtAreaBo bo) throws Exception;
+
+    Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) throws Exception;
+
 }

+ 11 - 0
ruoyi-api/ruoyi-api-backstage/src/main/java/org/dromara/backstage/api/RemotePtParameterService.java

@@ -1,5 +1,9 @@
 package org.dromara.backstage.api;
 
+import org.dromara.backstage.api.domain.bo.RemotePtParameterBo;
+
+import java.util.Collection;
+
 /**
  * name: RemotePtParameterService
  * package: org.dromara.backstage.api
@@ -18,4 +22,11 @@ public interface RemotePtParameterService {
      * @return 参数值
      */
     String getPtParameterByKey(String key);
+
+    Boolean insertByBo(RemotePtParameterBo bo) throws Exception;
+
+    Boolean updateByBo(RemotePtParameterBo bo) throws Exception;
+
+    Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) throws Exception;
+
 }

+ 20 - 0
ruoyi-api/ruoyi-api-backstage/src/main/java/org/dromara/backstage/api/RemotePtRoomService.java

@@ -0,0 +1,20 @@
+package org.dromara.backstage.api;
+
+import org.dromara.backstage.api.domain.bo.RemotePtRoomBatchSetBo;
+import org.dromara.backstage.api.domain.bo.RemotePtRoomBo;
+
+import java.util.Collection;
+
+/**
+ * 房间信息远程调用接口
+ */
+public interface RemotePtRoomService {
+
+    Boolean insertByBo(RemotePtRoomBo bo) throws Exception;
+
+    Boolean updateByBo(RemotePtRoomBo bo) throws Exception;
+
+    Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) throws Exception;
+
+    Boolean batchSet(RemotePtRoomBatchSetBo bo) throws Exception;
+}

+ 49 - 0
ruoyi-api/ruoyi-api-backstage/src/main/java/org/dromara/backstage/api/domain/bo/RemotePtMealTypeBo.java

@@ -0,0 +1,49 @@
+package org.dromara.backstage.api.domain.bo;
+
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * 营业时段业务对象 t_pt_mealType
+ *
+ * @author Yz
+ * @date 2024-08-05
+ */
+@Data
+@NoArgsConstructor
+public class RemotePtMealTypeBo implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+    /**
+     * 营业时段id
+     */
+    private Long mealId;
+
+    /**
+     * 餐类Id
+     */
+    private String typeId;
+    /**
+     * 餐类名称
+     */
+    private String mealName;
+
+    /**
+     * 开始时间
+     */
+    private String beginTime;
+
+    /**
+     * 结束时间
+     */
+    private String endTime;
+
+    /**
+     * 类别说明
+     */
+    private String mealNotes;
+
+
+}

+ 58 - 0
ruoyi-api/ruoyi-api-backstage/src/main/java/org/dromara/backstage/api/domain/bo/RemotePtParameterBo.java

@@ -0,0 +1,58 @@
+package org.dromara.backstage.api.domain.bo;
+
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * 系统参数业务对象 t_pt_parameter
+ *
+ * @author Yz
+ * @date 2024-08-06
+ */
+@Data
+@NoArgsConstructor
+public class RemotePtParameterBo implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 租户编号
+     */
+    private String tenantId;
+
+    /**
+     * 参数id
+     */
+    private Long paramId;
+
+    /**
+     * 参数编码
+     */
+    private String paramCode;
+
+    /**
+     * 参数名称
+     */
+    private String paramName;
+
+    /**
+     * 参数值
+     */
+    private String paramValue;
+
+    /**
+     * 参数备注
+     */
+    private String remark;
+
+    /**
+     * 系统参数
+     */
+    private String sysData;
+
+
+}

+ 37 - 0
ruoyi-api/ruoyi-api-backstage/src/main/java/org/dromara/backstage/api/domain/bo/RemotePtRoomBatchSetBo.java

@@ -0,0 +1,37 @@
+package org.dromara.backstage.api.domain.bo;
+
+import jakarta.validation.constraints.NotEmpty;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 房间定义业务对象 t_pt_room
+ *
+ * @author bing
+ * @date 2024-08-09
+ */
+@Data
+@NoArgsConstructor
+public class RemotePtRoomBatchSetBo implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 5953463621208429125L;
+    /**
+     * 房间Id,主键
+     */
+    private List<Long> roomIds;
+
+    /**
+     * 房间类型,见FJLX字典类型
+     */
+//    @NotBlank(message = "房间类型,见FJLX字典类型不能为空", groups = { AddGroup.class, EditGroup.class })
+    private String roomType;
+
+
+
+
+}

+ 75 - 0
ruoyi-api/ruoyi-api-backstage/src/main/java/org/dromara/backstage/api/domain/bo/RemotePtRoomBo.java

@@ -0,0 +1,75 @@
+package org.dromara.backstage.api.domain.bo;
+
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * 房间定义业务对象 t_pt_room
+ *
+ * @author bing
+ * @date 2024-08-09
+ */
+@Data
+@NoArgsConstructor
+public class RemotePtRoomBo implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+    /**
+     * 房间Id,主键
+     */
+    private Long roomId;
+
+    /**
+     * 所属区域id
+     */
+    private Long areaId;
+
+    /**
+     * 房间编码
+     */
+    private String roomCode;
+
+    /**
+     * 房间名称
+     */
+    private String roomName;
+
+    /**
+     * 房间类型,见FJLX字典类型
+     */
+    private String roomType;
+
+    /**
+     * 门牌号1
+     */
+    private String codeOne;
+
+    /**
+     * 门牌号2
+     */
+    private String codeTwo;
+
+    /**
+     * 门牌号3
+     */
+    private String codeThree;
+
+    /**
+     * 门牌号4
+     */
+    private String codeFour;
+
+    /**
+     * 门牌号5
+     */
+    private String codeFive;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+
+}

+ 16 - 0
ruoyi-common/ruoyi-common-message/src/main/java/org/dromara/common/message/kafka/constant/MessageEventTypeConstants.java

@@ -54,6 +54,22 @@ public class MessageEventTypeConstants {
      *     xfLimitedterm_EDIT("YKT_119_EDIT","设备绑定","消费设备-限次管理"),
      *     CLIENT_consumer_ADD("CLIENT_101_ADD","消费扣费","刷卡消费");
      */
+    /**
+     * 系统参数功能模块标识
+     */
+    public static final String PARAMETER_SENDER = "YKT_101";
+    /**
+     * 营业时段功能模块标识
+     */
+    public static final String MEAL_TYPE_SENDER = "YKT_103";
+    /**
+     * 房间信息功能模块标识
+     */
+    public static final String ROOM_SENDER = "YKT_105";
+    public static final String AREA_SENDER = "YKT_106";
+    /**
+     * 房间信息功能模块标识
+     */
     public static final String	ptParameter_ADD = "YKT_101_ADD";
     public static final String	ptParameter_EDIT = "YKT_101_EDIT";
     public static final String	ptParameter_REMOVE = "YKT_101_REMOVE";

+ 22 - 1
ruoyi-modules/ruoyi-backstage/src/main/java/org/dromara/backstage/basics/dubbo/RemoteMealTypeServiceImpl.java

@@ -1,13 +1,17 @@
 package org.dromara.backstage.basics.dubbo;
 
 
+import cn.hutool.core.bean.BeanUtil;
 import lombok.RequiredArgsConstructor;
 import org.apache.dubbo.config.annotation.DubboService;
 import org.dromara.backstage.api.RemoteMealTypeService;
-import org.dromara.backstage.basics.service.IPtCardtypeService;
+import org.dromara.backstage.api.domain.bo.RemotePtMealTypeBo;
+import org.dromara.backstage.basics.domain.bo.PtMealTypeBo;
 import org.dromara.backstage.basics.service.IPtMealtypeService;
 import org.springframework.stereotype.Service;
 
+import java.util.Collection;
+
 @RequiredArgsConstructor
 @Service
 @DubboService
@@ -18,4 +22,21 @@ public class RemoteMealTypeServiceImpl implements RemoteMealTypeService {
     public String selectMealTypeNameByIds(String ids) {
         return mealtypeService.selectMealTypeNameByIds(ids);
     }
+
+    @Override
+    public Boolean insertByBo(RemotePtMealTypeBo bo) throws Exception {
+        return mealtypeService.insertByBo(BeanUtil.toBean(bo, PtMealTypeBo.class));
+    }
+
+    @Override
+    public Boolean updateByBo(RemotePtMealTypeBo bo) throws Exception {
+        return mealtypeService.updateByBo(BeanUtil.toBean(bo, PtMealTypeBo.class));
+    }
+
+    @Override
+    public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) throws Exception {
+        return mealtypeService.deleteWithValidByIds(ids,isValid);
+    }
+
+
 }

+ 14 - 4
ruoyi-modules/ruoyi-backstage/src/main/java/org/dromara/backstage/basics/dubbo/RemotePtAreaServiceImpl.java

@@ -1,18 +1,17 @@
 package org.dromara.backstage.basics.dubbo;
 
+import cn.hutool.core.bean.BeanUtil;
 import lombok.RequiredArgsConstructor;
 import org.apache.dubbo.config.annotation.DubboService;
 import org.dromara.backstage.api.RemotePtAreaService;
-import org.dromara.backstage.api.RemotePtSchoolService;
 import org.dromara.backstage.api.domain.bo.RemotePtAreaBo;
-import org.dromara.backstage.api.domain.bo.RemotePtSchoolBo;
 import org.dromara.backstage.basics.domain.bo.PtAreaBo;
-import org.dromara.backstage.basics.domain.bo.PtSchoolBo;
 import org.dromara.backstage.basics.service.IPtAreaService;
-import org.dromara.backstage.basics.service.IPtSchoolService;
 import org.dromara.common.core.utils.MapstructUtils;
 import org.springframework.stereotype.Service;
 
+import java.util.Collection;
+
 /**
  * 用户服务
  *
@@ -31,4 +30,15 @@ public class RemotePtAreaServiceImpl implements RemotePtAreaService {
         PtAreaBo ptSchoolBo = MapstructUtils.convert(bo, PtAreaBo.class);
         return ptAreaService.insertByBo(ptSchoolBo);
     }
+
+    @Override
+    public Boolean updateByBo(RemotePtAreaBo bo) throws Exception {
+        return ptAreaService.updateByBo(BeanUtil.copyProperties(bo, PtAreaBo.class));
+    }
+
+    @Override
+    public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) throws Exception {
+        return ptAreaService.deleteWithValidByIds(ids, isValid);
+    }
+
 }

+ 22 - 0
ruoyi-modules/ruoyi-backstage/src/main/java/org/dromara/backstage/basics/dubbo/RemotePtParameterServiceImpl.java

@@ -1,11 +1,16 @@
 package org.dromara.backstage.basics.dubbo;
 
+import cn.hutool.core.bean.BeanUtil;
 import lombok.RequiredArgsConstructor;
 import org.apache.dubbo.config.annotation.DubboService;
 import org.dromara.backstage.api.RemotePtParameterService;
+import org.dromara.backstage.api.domain.bo.RemotePtParameterBo;
+import org.dromara.backstage.basics.domain.bo.PtParameterBo;
 import org.dromara.backstage.basics.service.IPtParameterService;
 import org.springframework.stereotype.Service;
 
+import java.util.Collection;
+
 /**
  * name: RemotePtParameterServiceImpl
  * package: org.dromara.backstage.basics.dubbo
@@ -25,4 +30,21 @@ public class RemotePtParameterServiceImpl implements RemotePtParameterService {
     public String getPtParameterByKey(String key) {
         return ptParameterService.selectParamByCode(key);
     }
+
+    @Override
+    public Boolean insertByBo(RemotePtParameterBo bo) throws Exception{
+        return ptParameterService.insertByBo(BeanUtil.toBean(bo, PtParameterBo.class));
+    }
+
+    @Override
+    public Boolean updateByBo(RemotePtParameterBo bo) throws Exception{
+        return ptParameterService.updateByBo(BeanUtil.toBean(bo, PtParameterBo.class));
+    }
+
+    @Override
+    public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) throws Exception{
+        return ptParameterService.deleteWithValidByIds(ids,isValid);
+    }
+
+
 }

+ 45 - 0
ruoyi-modules/ruoyi-backstage/src/main/java/org/dromara/backstage/basics/dubbo/RemotePtRoomServiceImpl.java

@@ -0,0 +1,45 @@
+package org.dromara.backstage.basics.dubbo;
+
+import cn.hutool.core.bean.BeanUtil;
+import lombok.RequiredArgsConstructor;
+import org.apache.dubbo.config.annotation.DubboService;
+import org.dromara.backstage.api.RemotePtRoomService;
+import org.dromara.backstage.api.domain.bo.RemotePtRoomBatchSetBo;
+import org.dromara.backstage.api.domain.bo.RemotePtRoomBo;
+import org.dromara.backstage.basics.domain.bo.PtRoomBatchSetBo;
+import org.dromara.backstage.basics.domain.bo.PtRoomBo;
+import org.dromara.backstage.basics.service.IPtRoomService;
+import org.springframework.stereotype.Service;
+
+import java.util.Collection;
+
+/**
+ * 房间信息远程服务实现类
+ */
+@RequiredArgsConstructor
+@Service
+@DubboService
+public class RemotePtRoomServiceImpl implements RemotePtRoomService {
+
+    private final  IPtRoomService iPtRoomService;
+    @Override
+    public Boolean insertByBo(RemotePtRoomBo bo) throws Exception {
+        return iPtRoomService.insertByBo(BeanUtil.toBean(bo, PtRoomBo.class));
+    }
+
+    @Override
+    public Boolean updateByBo(RemotePtRoomBo bo) throws Exception {
+        return iPtRoomService.updateByBo(BeanUtil.toBean(bo, PtRoomBo.class));
+    }
+
+    @Override
+    public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) throws Exception {
+        return iPtRoomService.deleteWithValidByIds(ids,isValid);
+    }
+
+    @Override
+    public Boolean batchSet(RemotePtRoomBatchSetBo bo) throws Exception {
+        return iPtRoomService.batchSet(BeanUtil.toBean(bo, PtRoomBatchSetBo.class));
+    }
+
+}

+ 12 - 0
ruoyi-server/ruoyi-server-base/pom.xml

@@ -35,5 +35,17 @@
             <groupId>org.dromara</groupId>
             <artifactId>ruoyi-common-redis</artifactId>
         </dependency>
+
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-json</artifactId>
+            <version>5.8.27</version>
+        </dependency>
+        <dependency>
+            <groupId>org.dromara</groupId>
+            <artifactId>ruoyi-api-backstage</artifactId>
+            <version>2.2.0</version>
+            <scope>compile</scope>
+        </dependency>
     </dependencies>
 </project>

+ 61 - 0
ruoyi-server/ruoyi-server-base/src/main/java/org/dromara/server/base/service/yktOperation/SyncRemotePtAreaService.java

@@ -0,0 +1,61 @@
+package org.dromara.server.base.service.yktOperation;
+
+import cn.hutool.json.JSONUtil;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.dubbo.config.annotation.DubboReference;
+import org.dromara.backstage.api.RemotePtAreaService;
+import org.dromara.backstage.api.RemotePtRoomService;
+import org.dromara.backstage.api.domain.bo.RemotePtAreaBo;
+import org.dromara.backstage.api.domain.bo.RemotePtRoomBatchSetBo;
+import org.dromara.backstage.api.domain.bo.RemotePtRoomBo;
+import org.dromara.common.core.exception.ServiceException;
+import org.springframework.stereotype.Service;
+
+import java.util.Collection;
+
+/**
+ * 系统参数同步
+ */
+@Service
+@Slf4j
+@RequiredArgsConstructor
+public class SyncRemotePtAreaService {
+
+    @DubboReference
+    private final RemotePtAreaService areaService;
+
+    /**
+     * 远程调用系统参数新增
+     * @param msg
+     */
+    public void addPtArea(Object msg) {
+        boolean flag = areaService.insertByBo(JSONUtil.parseObj(msg).toBean(RemotePtAreaBo.class));
+        if (!flag){
+            throw new ServiceException("区域信息新增失败");
+        }
+    }
+
+    /**
+     * 远程调用系统参数修改
+     * @param msg
+     */
+    public void editPtArea(Object msg) throws Exception{
+        boolean flag = areaService.updateByBo(JSONUtil.parseObj(msg).toBean(RemotePtAreaBo.class));
+        if (!flag){
+            throw new ServiceException("区域信息修改失败");
+        }
+    }
+
+    /**
+     * 远程调用系统参数删除
+     * @param msg
+     */
+    public void delPtArea(Object msg) throws Exception{
+        Collection<Long> ids = JSONUtil.parseArray(msg).toBean(Collection.class);
+        boolean flag = areaService.deleteWithValidByIds(ids,false);
+        if (!flag){
+            throw new ServiceException("区域删除失败");
+        }
+    }
+}

+ 60 - 0
ruoyi-server/ruoyi-server-base/src/main/java/org/dromara/server/base/service/yktOperation/SyncRemotePtMealTypeService.java

@@ -0,0 +1,60 @@
+package org.dromara.server.base.service.yktOperation;
+
+import cn.hutool.json.JSONUtil;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.dubbo.config.annotation.DubboReference;
+import org.dromara.backstage.api.RemoteMealTypeService;
+import org.dromara.backstage.api.RemotePtParameterService;
+import org.dromara.backstage.api.domain.bo.RemotePtMealTypeBo;
+import org.dromara.backstage.api.domain.bo.RemotePtParameterBo;
+import org.dromara.common.core.exception.ServiceException;
+import org.springframework.stereotype.Service;
+
+import java.util.Collection;
+
+/**
+ * 系统参数同步
+ */
+@Service
+@Slf4j
+@RequiredArgsConstructor
+public class SyncRemotePtMealTypeService {
+
+    @DubboReference
+    private final RemoteMealTypeService mealTypeService;
+
+    /**
+     * 远程调用系统参数新增
+     * @param msg
+     */
+    public void addPtMealType(Object msg) throws Exception{
+        boolean flag = mealTypeService.insertByBo(JSONUtil.parseObj(msg).toBean(RemotePtMealTypeBo.class));
+        if (!flag){
+            throw new ServiceException("营业时段新增失败");
+        }
+    }
+
+    /**
+     * 远程调用系统参数修改
+     * @param msg
+     */
+    public void editPtMealType(Object msg) throws Exception{
+        boolean flag = mealTypeService.updateByBo(JSONUtil.parseObj(msg).toBean(RemotePtMealTypeBo.class));
+        if (!flag){
+            throw new ServiceException("营业时段修改失败");
+        }
+    }
+
+    /**
+     * 远程调用系统参数删除
+     * @param msg
+     */
+    public void delPtMealType(Object msg) throws Exception{
+        Collection<Long> ids = JSONUtil.parseArray(msg).toBean(Collection.class);
+        boolean flag = mealTypeService.deleteWithValidByIds(ids,false);
+        if (!flag){
+            throw new ServiceException("营业时段删除失败");
+        }
+    }
+}

+ 41 - 1
ruoyi-server/ruoyi-server-base/src/main/java/org/dromara/server/base/service/yktOperation/SyncRemotePtParameterService.java

@@ -1,9 +1,16 @@
 package org.dromara.server.base.service.yktOperation;
 
+import cn.hutool.json.JSONUtil;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.dubbo.config.annotation.DubboReference;
+import org.dromara.backstage.api.RemotePtParameterService;
+import org.dromara.backstage.api.domain.bo.RemotePtParameterBo;
+import org.dromara.common.core.exception.ServiceException;
 import org.springframework.stereotype.Service;
 
+import java.util.Collection;
+
 /**
  * 系统参数同步
  */
@@ -12,7 +19,40 @@ import org.springframework.stereotype.Service;
 @RequiredArgsConstructor
 public class SyncRemotePtParameterService {
 
-    public void addPtParameter(){
+    @DubboReference
+    private final RemotePtParameterService remotePtParameterService;
+
+    /**
+     * 远程调用系统参数新增
+     * @param msg
+     */
+    public void addPtParameter(Object msg) throws Exception{
+        boolean flag = remotePtParameterService.insertByBo(JSONUtil.parseObj(msg).toBean(RemotePtParameterBo.class));
+        if (!flag){
+            throw new ServiceException("系统参数新增失败");
+        }
+    }
+
+    /**
+     * 远程调用系统参数修改
+     * @param msg
+     */
+    public void editPtParameter(Object msg) throws Exception{
+        boolean flag = remotePtParameterService.updateByBo(JSONUtil.parseObj(msg).toBean(RemotePtParameterBo.class));
+        if (!flag){
+            throw new ServiceException("系统参数修改失败");
+        }
+    }
 
+    /**
+     * 远程调用系统参数删除
+     * @param msg
+     */
+    public void delPtParameter(Object msg) throws Exception{
+        Collection<Long> ids = JSONUtil.parseArray(msg).toBean(Collection.class);
+        boolean flag = remotePtParameterService.deleteWithValidByIds(ids,false);
+        if (!flag){
+            throw new ServiceException("系统参数删除失败");
+        }
     }
 }

+ 66 - 0
ruoyi-server/ruoyi-server-base/src/main/java/org/dromara/server/base/service/yktOperation/SyncRemotePtRoomService.java

@@ -0,0 +1,66 @@
+package org.dromara.server.base.service.yktOperation;
+
+import cn.hutool.json.JSONUtil;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.dubbo.config.annotation.DubboReference;
+import org.dromara.backstage.api.RemotePtRoomService;
+import org.dromara.backstage.api.domain.bo.RemotePtRoomBatchSetBo;
+import org.dromara.backstage.api.domain.bo.RemotePtRoomBo;
+import org.dromara.common.core.exception.ServiceException;
+import org.springframework.stereotype.Service;
+
+import java.util.Collection;
+
+/**
+ * 系统参数同步
+ */
+@Service
+@Slf4j
+@RequiredArgsConstructor
+public class SyncRemotePtRoomService {
+
+    @DubboReference
+    private final RemotePtRoomService roomService;
+
+    /**
+     * 远程调用系统参数新增
+     * @param msg
+     */
+    public void addPtRoom(Object msg) throws Exception{
+        boolean flag = roomService.insertByBo(JSONUtil.parseObj(msg).toBean(RemotePtRoomBo.class));
+        if (!flag){
+            throw new ServiceException("房间信息新增失败");
+        }
+    }
+
+    /**
+     * 远程调用系统参数修改
+     * @param msg
+     */
+    public void editPtRoom(Object msg) throws Exception{
+        boolean flag = roomService.updateByBo(JSONUtil.parseObj(msg).toBean(RemotePtRoomBo.class));
+        if (!flag){
+            throw new ServiceException("房间信息修改失败");
+        }
+    }
+
+    /**
+     * 远程调用系统参数删除
+     * @param msg
+     */
+    public void delPtRoom(Object msg) throws Exception{
+        Collection<Long> ids = JSONUtil.parseArray(msg).toBean(Collection.class);
+        boolean flag = roomService.deleteWithValidByIds(ids,false);
+        if (!flag){
+            throw new ServiceException("房间删除失败");
+        }
+    }
+
+    public void batchSet(Object msg) throws Exception{
+        boolean flag = roomService.batchSet(JSONUtil.parseObj(msg).toBean(RemotePtRoomBatchSetBo.class));
+        if (!flag){
+            throw new ServiceException("房间批量设置失败");
+        }
+    }
+}

+ 3 - 0
ruoyi-server/ruoyi-server-base/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports

@@ -9,3 +9,6 @@ org.dromara.server.base.service.user.strategy.impl.SyncTeacherStrategyImpl
 org.dromara.server.base.service.user.strategy.impl.SyncGraduateStrategyImpl
 org.dromara.server.base.service.user.strategy.impl.SyncTraineeStrategyImpl
 org.dromara.server.base.service.yktOperation.SyncRemotePtParameterService
+org.dromara.server.base.service.yktOperation.SyncRemotePtMealTypeService
+org.dromara.server.base.service.yktOperation.SyncRemotePtRoomService
+org.dromara.server.base.service.yktOperation.SyncRemotePtAreaService

+ 19 - 11
ruoyi-server/ruoyi-server-mqdata/src/main/java/org/dromara/server/mq/consumer/KafkaConsumer.java

@@ -2,14 +2,16 @@ package org.dromara.server.mq.consumer;
 
 import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
-import lombok.Data;
+import com.alibaba.nacos.api.config.annotation.NacosValue;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.kafka.clients.consumer.ConsumerRecord;
 import org.dromara.common.message.kafka.domain.KafkaMessage;
 import org.dromara.server.mq.event.kafka.EventStrategyContext;
 import org.dromara.server.mq.event.kafka.YktEventStrategyContext;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.kafka.annotation.KafkaListener;
+import org.springframework.stereotype.Component;
 
 import static org.dromara.common.message.kafka.constant.KafkaTopicConstants.SYNC_DATA_TOPIC;
 
@@ -25,11 +27,14 @@ import static org.dromara.common.message.kafka.constant.KafkaTopicConstants.SYNC
  */
 @RequiredArgsConstructor
 @Slf4j
-//@Component
+@Component
 public class KafkaConsumer {
     private final EventStrategyContext eventStrategyContext;
     private final YktEventStrategyContext yktEventStrategyContext;
-    @KafkaListener(topics = "eventBus", groupId = "test-group-id")
+    @Value("${spring.system.tenantId}")
+    private String tenantId;
+
+//    @KafkaListener(topics = "eventBus", groupId = "test-group-id")
     public void kafkaReceiveHandler(ConsumerRecord<String, String> record) {
         KafkaMessage<?> receiveMsg = JSONUtil.toBean(record.value(), KafkaMessage.class);
         log.info("[接收到Kafka消息]-[{}]", receiveMsg);
@@ -47,19 +52,22 @@ public class KafkaConsumer {
      * 一卡通云端业务操作本地同步处理
      * @param record kafka消息
      */
-    @KafkaListener(topics = SYNC_DATA_TOPIC, groupId = "ykt_local_listener")
+    @KafkaListener(topics = SYNC_DATA_TOPIC, groupId = "YTK_${spring.system.tenantId}")
     public void cloudOperationSync(ConsumerRecord<String, String> record){
-        KafkaMessage<?> receiveMsg = JSONUtil.toBean(record.value(), KafkaMessage.class);
-        log.info("[接收到Kafka消息]-[{}]", receiveMsg);
         try{
+            KafkaMessage<?> receiveMsg = JSONUtil.toBean(record.value(), KafkaMessage.class);
+            log.info("[接收到Kafka消息]-[{}]", receiveMsg);
+            String tenantId = receiveMsg.getHeader().getTenantId();
+            if(!tenantId.equals(this.tenantId)){
+                log.info("消息所属租户不匹配");
+                return;
+            }
             String eventType = receiveMsg.getHeader().getEventType();
-    //          String tenantId = receiveMsg.getHeader().getTenantId();
-            String tenantId = "";
-            JSONObject eventMsg = JSONUtil.parseObj(receiveMsg.getBody());
-            yktEventStrategyContext.doMsgHandle(eventType, eventMsg);
+            String sender = receiveMsg.getHeader().getSender();
 
+            yktEventStrategyContext.doMsgHandle(sender, eventType, receiveMsg.getBody());
         } catch (Exception e){
-            log.error("[kafka消息处理失败]-[消息:{}-[错误:{}]", receiveMsg, e.getMessage());
+            log.error("[kafka消息处理失败]-[消息:{}-[错误:{}]", record.value(), e.getMessage(), e);
 
         }
     }

+ 1 - 1
ruoyi-server/ruoyi-server-mqdata/src/main/java/org/dromara/server/mq/event/kafka/IYktEventStrategy.java

@@ -11,5 +11,5 @@ public interface IYktEventStrategy {
      * @param eventType 事件类型
      * @param msg 消息体
      */
-    void doMsgHandle(String eventType,JSONObject msg);
+    void doMsgHandle(String eventType,Object msg) throws Exception;
 }

+ 2 - 3
ruoyi-server/ruoyi-server-mqdata/src/main/java/org/dromara/server/mq/event/kafka/YktEventStrategyContext.java

@@ -1,6 +1,5 @@
 package org.dromara.server.mq.event.kafka;
 
-import cn.hutool.json.JSONObject;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -19,7 +18,7 @@ public class YktEventStrategyContext {
         this.strategyMap.putAll(strategyMap);
     }
 
-    public void doMsgHandle(String eventType, JSONObject msg) {
-        strategyMap.get(eventType).doMsgHandle(eventType, msg);
+    public void doMsgHandle(String sender, String eventType,Object msg) throws Exception{
+        strategyMap.get(sender).doMsgHandle(eventType, msg);
     }
 }

+ 44 - 0
ruoyi-server/ruoyi-server-mqdata/src/main/java/org/dromara/server/mq/event/kafka/impl/yktOperation/PtAreaEventStrategyImpl.java

@@ -0,0 +1,44 @@
+package org.dromara.server.mq.event.kafka.impl.yktOperation;
+
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.dromara.common.message.kafka.constant.MessageEventTypeConstants;
+import org.dromara.server.base.service.yktOperation.SyncRemotePtAreaService;
+import org.dromara.server.base.service.yktOperation.SyncRemotePtRoomService;
+import org.dromara.server.mq.event.kafka.IYktEventStrategy;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author Hz
+ * @date 2024/10/29
+ * @description 营业时段功能同步策略
+ */
+@Slf4j
+@RequiredArgsConstructor
+@Service(MessageEventTypeConstants.AREA_SENDER)
+public class PtAreaEventStrategyImpl implements IYktEventStrategy {
+
+    private final SyncRemotePtAreaService areaService;
+    @Override
+    public void doMsgHandle(String eventType, Object msg) throws Exception{
+
+        switch (eventType) {
+            case MessageEventTypeConstants.ptArea_ADD:{
+                areaService.addPtArea(msg);
+            }
+            break;
+            case MessageEventTypeConstants.ptArea_EDIT:{
+                areaService.editPtArea(msg);
+            }
+            break;
+            case MessageEventTypeConstants.ptArea_REMOVE:{
+                areaService.delPtArea(msg);
+            }
+            break;
+            default:
+                log.info("未知事件");
+
+        }
+    }
+
+}

+ 43 - 0
ruoyi-server/ruoyi-server-mqdata/src/main/java/org/dromara/server/mq/event/kafka/impl/yktOperation/PtMealTypeEventStrategyImpl.java

@@ -0,0 +1,43 @@
+package org.dromara.server.mq.event.kafka.impl.yktOperation;
+
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.dromara.common.message.kafka.constant.MessageEventTypeConstants;
+import org.dromara.server.base.service.yktOperation.SyncRemotePtMealTypeService;
+import org.dromara.server.mq.event.kafka.IYktEventStrategy;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author Hz
+ * @date 2024/10/29
+ * @description 营业时段功能同步策略
+ */
+@Slf4j
+@RequiredArgsConstructor
+@Service(MessageEventTypeConstants.MEAL_TYPE_SENDER)
+public class PtMealTypeEventStrategyImpl implements IYktEventStrategy {
+
+    private final SyncRemotePtMealTypeService mealTypeService;
+    @Override
+    public void doMsgHandle(String eventType, Object msg) throws Exception{
+
+        switch (eventType) {
+            case MessageEventTypeConstants.ptMealtype_ADD:{
+                mealTypeService.addPtMealType(msg);
+            }
+            break;
+            case MessageEventTypeConstants.ptMealtype_EDIT:{
+                mealTypeService.editPtMealType(msg);
+            }
+            break;
+            case MessageEventTypeConstants.ptMealtype_REMOVE:{
+                mealTypeService.delPtMealType(msg);
+            }
+            break;
+            default:
+                log.info("未知事件");
+
+        }
+    }
+
+}

+ 10 - 11
ruoyi-server/ruoyi-server-mqdata/src/main/java/org/dromara/server/mq/event/kafka/impl/yktOperation/PtParameterEventStrategyImpl.java

@@ -1,11 +1,9 @@
 package org.dromara.server.mq.event.kafka.impl.yktOperation;
 
-import cn.hutool.json.JSONObject;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
-import org.dromara.server.base.service.dept.SyncRemoteDeptService;
+import org.dromara.common.message.kafka.constant.MessageEventTypeConstants;
 import org.dromara.server.base.service.yktOperation.SyncRemotePtParameterService;
-import org.dromara.server.mq.constant.kafka.YktOperationEventConstraints;
 import org.dromara.server.mq.event.kafka.IYktEventStrategy;
 import org.springframework.stereotype.Service;
 
@@ -16,23 +14,24 @@ import org.springframework.stereotype.Service;
  */
 @Slf4j
 @RequiredArgsConstructor
-@Service(YktOperationEventConstraints.PARAMETER_SENDER)
+@Service(MessageEventTypeConstants.PARAMETER_SENDER)
 public class PtParameterEventStrategyImpl implements IYktEventStrategy {
 
     private final SyncRemotePtParameterService parameterService;
     @Override
-    public void doMsgHandle(String eventType, JSONObject msg) {
+    public void doMsgHandle(String eventType, Object msg) throws Exception{
+
         switch (eventType) {
-            case YktOperationEventConstraints.PARAMETER_ADD:{
-                log.info("新增系统参数");
+            case MessageEventTypeConstants.ptParameter_ADD :{
+                parameterService.addPtParameter(msg);
             }
             break;
-            case YktOperationEventConstraints.PARAMETER_EDIT:{
-                log.info("修改系统参数");
+            case MessageEventTypeConstants.ptParameter_EDIT:{
+                parameterService.editPtParameter(msg);
             }
             break;
-            case YktOperationEventConstraints.PARAMETER_DEL:{
-                log.info("删除系统参数");
+            case MessageEventTypeConstants.ptParameter_REMOVE:{
+                parameterService.delPtParameter(msg);
             }
             break;
             default:

+ 48 - 0
ruoyi-server/ruoyi-server-mqdata/src/main/java/org/dromara/server/mq/event/kafka/impl/yktOperation/PtRoomEventStrategyImpl.java

@@ -0,0 +1,48 @@
+package org.dromara.server.mq.event.kafka.impl.yktOperation;
+
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.dromara.common.message.kafka.constant.MessageEventTypeConstants;
+import org.dromara.server.base.service.yktOperation.SyncRemotePtMealTypeService;
+import org.dromara.server.base.service.yktOperation.SyncRemotePtRoomService;
+import org.dromara.server.mq.event.kafka.IYktEventStrategy;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author Hz
+ * @date 2024/10/29
+ * @description 营业时段功能同步策略
+ */
+@Slf4j
+@RequiredArgsConstructor
+@Service(MessageEventTypeConstants.ROOM_SENDER)
+public class PtRoomEventStrategyImpl implements IYktEventStrategy {
+
+    private final SyncRemotePtRoomService roomService;
+    @Override
+    public void doMsgHandle(String eventType, Object msg) throws Exception{
+
+        switch (eventType) {
+            case MessageEventTypeConstants.ptRoom_ADD:{
+                roomService.addPtRoom(msg);
+            }
+            break;
+            case MessageEventTypeConstants.ptRoom_EDIT:{
+                roomService.editPtRoom(msg);
+            }
+            break;
+            case MessageEventTypeConstants.ptRoom_REMOVE:{
+                roomService.delPtRoom(msg);
+            }
+            break;
+            case MessageEventTypeConstants.ptRoom_SET:{
+                roomService.batchSet(msg);
+            }
+            break;
+            default:
+                log.info("未知事件");
+
+        }
+    }
+
+}