From 4b4c69c8fb8b3ddc7fd932b122dca7faeedf2cab Mon Sep 17 00:00:00 2001 From: "H.X" <7458466+huangxing1023@user.noreply.gitee.com> Date: Tue, 14 Mar 2023 17:14:15 +0800 Subject: [PATCH] =?UTF-8?q?#=20=E6=8E=A5=E7=AB=99=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hzims-service-api/hzims-operational-api/pom.xml | 6 +- .../config/entity/FocusAttributeEntity.java | 5 +- .../operational/station/entity/StationEntity.java | 13 ++-- hzims-service/equipment/pom.xml | 5 ++ .../controller/EquipmentLedgerController.java | 3 + .../hzims/monitor/server/RealTimeDataServer.java | 3 + .../server/impl/RealTimeDataServerImpl.java | 6 +- .../monitor/service/IModelInstanceService.java | 19 ++++++ .../service/impl/ModelInstanceServiceImpl.java | 26 ++++++++ hzims-service/operational/pom.xml | 14 +++- .../station/controller/StationController.java | 38 ++++++----- .../station/service/IStationService.java | 6 ++ .../station/service/impl/StationServiceImpl.java | 78 ++++++++++++++++++++++ hzims-service/pom.xml | 2 +- .../ticket/redisConsume/RedisMessageTopic.java | 12 ++++ .../ticket/redisConsume/WorkTicketMsgConsume.java | 27 ++++++++ hzims-service/weather/pom.xml | 7 ++ .../hnac/hzims/weather/consume/ConsumerMsg.java | 25 +++++++ .../weather/supplier/RedisMsgSupplyController.java | 30 +++++++++ pom.xml | 2 +- 20 files changed, 296 insertions(+), 31 deletions(-) create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/monitor/service/IModelInstanceService.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/monitor/service/impl/ModelInstanceServiceImpl.java create mode 100644 hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/redisConsume/RedisMessageTopic.java create mode 100644 hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/redisConsume/WorkTicketMsgConsume.java create mode 100644 hzims-service/weather/src/main/java/com/hnac/hzims/weather/consume/ConsumerMsg.java create mode 100644 hzims-service/weather/src/main/java/com/hnac/hzims/weather/supplier/RedisMsgSupplyController.java diff --git a/hzims-service-api/hzims-operational-api/pom.xml b/hzims-service-api/hzims-operational-api/pom.xml index 928b5a9..8e5eb61 100644 --- a/hzims-service-api/hzims-operational-api/pom.xml +++ b/hzims-service-api/hzims-operational-api/pom.xml @@ -58,8 +58,7 @@ com.hnac.hzinfo.data hzinfo-data-sdk - ${hzinfo.data.version} - compile + 4.6.0-SNAPSHOT @@ -70,8 +69,7 @@ org.springblade blade-system-api - 4.5.3.RELEASE - compile + 4.5.8.RELEASE diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/config/entity/FocusAttributeEntity.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/config/entity/FocusAttributeEntity.java index 9ef2ee2..8274fb7 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/config/entity/FocusAttributeEntity.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/config/entity/FocusAttributeEntity.java @@ -22,7 +22,7 @@ import java.io.Serializable; @NoArgsConstructor @Builder @TableName("hzims_focus_attribute") -public class FocusAttributeEntity extends TenantEntity implements Serializable { +public class FocusAttributeEntity extends TenantEntity implements Serializable { private static final long serialVersionUID = 4252785650034702695L; @ApiModelProperty(value = "分组ID",required = true) @@ -67,4 +67,7 @@ public class FocusAttributeEntity extends TenantEntity implements Serializable { @ApiModelProperty("单位") private String unit; + + @ApiModelProperty("监测点映射标识") + private String signage; } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/StationEntity.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/StationEntity.java index 014f4e7..4364f2b 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/StationEntity.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/StationEntity.java @@ -17,6 +17,7 @@ import org.springblade.core.tenant.mp.TenantEntity; import org.springblade.core.tool.utils.DateUtil; import org.springframework.format.annotation.DateTimeFormat; +import javax.validation.constraints.NotNull; import java.io.Serializable; import java.time.LocalDate; import java.time.LocalDateTime; @@ -28,10 +29,6 @@ import java.time.LocalDateTime; @NoArgsConstructor public class StationEntity extends TenantEntity implements Serializable { private static final long serialVersionUID = -4381363806216436570L; - - @ApiModelProperty("主键ID") - private Long id; - @ApiModelProperty("所属领域(来源于字典表如水电)") @JsonSerialize(nullsUsing = NullSerializer.class) @QueryField(condition = SqlCondition.EQUAL) @@ -51,6 +48,11 @@ public class StationEntity extends TenantEntity implements Serializable { @QueryField(condition = SqlCondition.EQUAL) private String areaCode; + @ApiModelProperty("上属机构") + @QueryField(condition = SqlCondition.EQUAL) + @NotNull + private Long higherDept; + @ApiModelProperty("所属机构") @QueryField(condition = SqlCondition.EQUAL) @JsonSerialize(nullsUsing = NullSerializer.class) @@ -58,10 +60,12 @@ public class StationEntity extends TenantEntity implements Serializable { @ApiModelProperty("编号(原站点ID)") @QueryField(condition = SqlCondition.LIKE) + @NotNull private String code; @ApiModelProperty("名称") @QueryField(condition = SqlCondition.LIKE) + @NotNull private String name; @DateTimeFormat( @@ -79,6 +83,7 @@ public class StationEntity extends TenantEntity implements Serializable { @ApiModelProperty("类型(1电站2泵站3水厂)") @QueryField(condition = SqlCondition.EQUAL) @JsonSerialize(nullsUsing = NullSerializer.class) + @NotNull private Integer type; @ApiModelProperty("前池最高水位") diff --git a/hzims-service/equipment/pom.xml b/hzims-service/equipment/pom.xml index e16a363..d2f3d79 100644 --- a/hzims-service/equipment/pom.xml +++ b/hzims-service/equipment/pom.xml @@ -98,6 +98,11 @@ 1.0.0 + + com.hnac.hzinfo + hzinfo-data-sdk + 4.6.0-SNAPSHOT + com.hnac.hzims diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/monitor/controller/EquipmentLedgerController.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/monitor/controller/EquipmentLedgerController.java index 30a3a6b..245f61d 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/monitor/controller/EquipmentLedgerController.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/monitor/controller/EquipmentLedgerController.java @@ -2,10 +2,13 @@ package com.hnac.hzims.monitor.controller; import com.hnac.hzims.monitor.server.HistoricalDataServer; import com.hnac.hzims.monitor.server.RealTimeDataServer; +import com.hnac.hzinfo.dataconfig.deviceInstace.DeviceInstance; +import com.hnac.hzinfo.dataconfig.deviceInstace.DeviceInstanceAttr; import com.hnac.hzinfo.dataconfig.entity.*; import com.hnac.hzinfo.datasearch.analyse.domain.AnalyzeDataCondition; import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData; import com.hnac.hzinfo.datasearch.real.po.RealDataSearchPO; +import com.hnac.hzinfo.sdk.analyse.vo.AnalyzeModel; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/monitor/server/RealTimeDataServer.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/monitor/server/RealTimeDataServer.java index abe9499..72d1fd3 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/monitor/server/RealTimeDataServer.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/monitor/server/RealTimeDataServer.java @@ -1,9 +1,12 @@ package com.hnac.hzims.monitor.server; +import com.hnac.hzinfo.dataconfig.deviceInstace.DeviceInstance; +import com.hnac.hzinfo.dataconfig.deviceInstace.DeviceInstanceAttr; import com.hnac.hzinfo.dataconfig.entity.*; import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData; import com.hnac.hzinfo.datasearch.real.po.RealDataSearchPO; +import com.hnac.hzinfo.sdk.analyse.vo.AnalyzeModel; import org.springblade.core.tool.api.R; import java.util.List; diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/monitor/server/impl/RealTimeDataServerImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/monitor/server/impl/RealTimeDataServerImpl.java index 9ef7158..b11e1f3 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/monitor/server/impl/RealTimeDataServerImpl.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/monitor/server/impl/RealTimeDataServerImpl.java @@ -4,14 +4,18 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.mapper.EmInfoMapper; import com.hnac.hzims.monitor.server.RealTimeDataServer; +import com.hnac.hzinfo.dataconfig.device.IDeviceClient; +import com.hnac.hzinfo.dataconfig.deviceInstace.DeviceInstance; +import com.hnac.hzinfo.dataconfig.deviceInstace.DeviceInstanceAttr; import com.hnac.hzinfo.dataconfig.entity.*; import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient; import com.hnac.hzinfo.datasearch.analyse.IAnalyseInstanceClient; import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData; -import com.hnac.hzinfo.datasearch.device.IDeviceClient; + import com.hnac.hzinfo.datasearch.real.IRealDataSearchClient; import com.hnac.hzinfo.datasearch.real.po.RealDataSearchPO; +import com.hnac.hzinfo.sdk.analyse.vo.AnalyzeModel; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.tool.api.R; diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/monitor/service/IModelInstanceService.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/monitor/service/IModelInstanceService.java new file mode 100644 index 0000000..0028e84 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/monitor/service/IModelInstanceService.java @@ -0,0 +1,19 @@ +package com.hnac.hzims.monitor.service; + +import com.hnac.hzinfo.sdk.analyse.dto.AnalyseDataHandlerDTO; + +/** + * @author hx + * @version 1.0 + * @date 2023/3/12 14:38 + */ +public interface IModelInstanceService { + + /** + * 新建设备模型实例 + * @param analyseDataHandlerDTO 模型实例 + * @return + */ + boolean save(AnalyseDataHandlerDTO analyseDataHandlerDTO); + +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/monitor/service/impl/ModelInstanceServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/monitor/service/impl/ModelInstanceServiceImpl.java new file mode 100644 index 0000000..f07554b --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/monitor/service/impl/ModelInstanceServiceImpl.java @@ -0,0 +1,26 @@ +package com.hnac.hzims.monitor.service.impl; + +import com.hnac.hzims.monitor.service.IModelInstanceService; +import com.hnac.hzinfo.sdk.analyse.AnalyseDataHandlerClient; +import com.hnac.hzinfo.sdk.analyse.dto.AnalyseDataHandlerDTO; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +/** + * @author hx + * @version 1.0 + * @date 2023/3/12 14:38 + */ +@Service +@AllArgsConstructor +@Slf4j +public class ModelInstanceServiceImpl implements IModelInstanceService { + private final AnalyseDataHandlerClient analyseDataHandlerClient; + + @Override + public boolean save(AnalyseDataHandlerDTO analyseDataHandlerDTO) { + //analyseDataHandlerClient.save(analyseDataHandlerDTO); + return true; + } +} diff --git a/hzims-service/operational/pom.xml b/hzims-service/operational/pom.xml index cd6ffd1..ce5703e 100644 --- a/hzims-service/operational/pom.xml +++ b/hzims-service/operational/pom.xml @@ -259,8 +259,12 @@ org.springblade blade-system-api - 4.5.0.RELEASE - compile + 4.5.8.RELEASE + + + com.hnac.hzinfo + hzinfo-data-sdk + 4.6.0-SNAPSHOT org.springblade @@ -276,6 +280,12 @@ 4.5.3.RELEASE compile + + org.springblade + blade-system-api + 4.5.8.RELEASE + compile + diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationController.java index 58e2bf0..3d9c032 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationController.java @@ -1,4 +1,4 @@ -package com.hnac.hzims.operational.station.controller; + package com.hnac.hzims.operational.station.controller; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -66,17 +66,19 @@ public class StationController extends BladeController { @ApiOperationSupport(order = 20) @ApiOperation(value = "新增") public R save(@Valid @RequestBody StationEntity req) { - List list = stationService.list(new LambdaQueryWrapper(){{ - eq(StationEntity::getCode,req.getCode()).or().eq(StationEntity::getName,req.getName()); - }}); - Optional sort = Optional.ofNullable(stationService.getStationMaxOrder()); - req.setSort(sort.isPresent() ? sort.get()+1 : 1); - // 刷新演示平台站点数量 - Executors.newSingleThreadExecutor().submit(() -> { - dataServicel.saveStation(); - return "success"; - }); - return list.size()>0 ? R.fail(400,"该站点名/编码已有对应记录,请找到相应记录做修改处理") : R.status(stationService.save(req)); + stationService.buildStation(req); + return R.success("保存成功!"); +// List list = stationService.list(new LambdaQueryWrapper(){{ +// eq(StationEntity::getCode,req.getCode()).or().eq(StationEntity::getName,req.getName()); +// }}); +// Optional sort = Optional.ofNullable(stationService.getStationMaxOrder()); +// req.setSort(sort.isPresent() ? sort.get()+1 : 1); +// // 刷新演示平台站点数量 +// Executors.newSingleThreadExecutor().submit(() -> { +// dataServicel.saveStation(); +// return "success"; +// }); +// return list.size()>0 ? R.fail(400,"该站点名/编码已有对应记录,请找到相应记录做修改处理") : R.status(stationService.save(req)); } /** @@ -86,11 +88,13 @@ public class StationController extends BladeController { @ApiOperationSupport(order = 30) @ApiOperation(value = "修改", notes = "传入StationEntity") public R update(@Valid @RequestBody StationEntity req) { - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper(); - queryWrapper.ne(StationEntity::getId,req.getId()); - queryWrapper.and(wrapper -> wrapper.eq(StationEntity::getCode,req.getCode()).or().eq(StationEntity::getName,req.getName())); - List list = stationService.list(queryWrapper); - return list.size()>0 ? R.fail(400,"该站点名/编码已有对应记录,请找到相应记录做修改处理") : R.status(stationService.updateById(req)); + stationService.buildStation(req); + return R.success("修改成功!"); +// LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper(); +// queryWrapper.ne(StationEntity::getId,req.getId()); +// queryWrapper.and(wrapper -> wrapper.eq(StationEntity::getCode,req.getCode()).or().eq(StationEntity::getName,req.getName())); +// List list = stationService.list(queryWrapper); +// return list.size()>0 ? R.fail(400,"该站点名/编码已有对应记录,请找到相应记录做修改处理") : R.status(stationService.updateById(req)); } @PostMapping("/updateBatch") diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java index 8411a7a..b35f413 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java @@ -23,6 +23,12 @@ import java.util.Map; */ public interface IStationService extends BaseService { + /** + * 新建站点 + * @param req 站点信息 + */ + void buildStation(StationEntity req); + IPage list(StationEntity req, Query query); List getUsersByStationId(String stationId); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java index a3637e3..fe0809c 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java @@ -1,11 +1,14 @@ package com.hnac.hzims.operational.station.service.impl; +import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hnac.hzims.common.service.UserAuthDataService; import com.hnac.hzims.operational.OperationalConstants; +import com.hnac.hzims.operational.data.service.HzimsDataService; import com.hnac.hzims.operational.main.vo.StationCountVo; +import com.hnac.hzims.operational.station.StationConstants; import com.hnac.hzims.operational.station.entity.ControlUsersEntity; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.mapper.ControlUsersMapper; @@ -15,10 +18,14 @@ import com.hnac.hzims.operational.station.vo.HzimsStationCountVo; import com.hnac.hzims.operational.station.vo.StationAndDeptVo; import com.hnac.hzims.operational.station.vo.StationVO; import com.hnac.hzims.operational.station.wrapper.StationWrapper; +import com.hnac.hzinfo.sdk.core.response.Result; +import com.hnac.hzinfo.sdk.project.ProjectClient; +import com.hnac.hzinfo.sdk.project.dto.ProjectDTO; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.log.logger.BladeLogger; import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; @@ -27,13 +34,16 @@ import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.*; import org.springblade.system.entity.Dept; +import org.springblade.system.feign.IDeptClient; import org.springblade.system.feign.ISysClient; import org.springblade.system.user.entity.User; + import org.springblade.system.user.feign.IUserClient; import org.springframework.stereotype.Service; import org.springframework.util.Assert; import java.util.*; +import java.util.concurrent.Executors; import java.util.stream.Collectors; /** @@ -44,8 +54,46 @@ import java.util.stream.Collectors; @Slf4j public class StationServiceImpl extends BaseServiceImpl implements IStationService { private final ISysClient sysClient; + private final IDeptClient deptClient; private final UserAuthDataService userAuthDataService; private final IUserClient userClient; + private final ProjectClient projectClient; + private final BladeLogger logger; + + @Override + public void buildStation(StationEntity req) { + // 新建站点的所属机构 + Assert.isTrue(this.buildDept(req),() -> { + throw new ServiceException("创建/修改机构失败!"); + }); + LambdaQueryWrapper lwq; + if(Func.isEmpty(req.getId())) { + lwq = Wrappers.lambdaQuery() + .eq(StationEntity::getCode,req.getCode()).or().eq(StationEntity::getName,req.getName()); + } + else { + lwq = Wrappers.lambdaQuery().ne(StationEntity::getId,req.getId()) + .and(wrapper -> wrapper.eq(StationEntity::getCode,req.getCode()).or().eq(StationEntity::getName,req.getName())); + } + + List list = super.list(lwq); + Assert.isTrue(CollectionUtil.isEmpty(list),() -> { + throw new ServiceException("该站点名/编码已有对应记录,请找到相应记录做修改处理"); + }); + Optional sort = Optional.ofNullable(this.getStationMaxOrder()); + req.setSort(sort.isPresent() ? sort.get()+1 : 1); + Assert.isTrue(this.saveOrUpdate(req),() -> { + throw new ServiceException("创建/修改站点信息失败!"); + }); + // 为画面导入创建工程 + new Thread(() -> { + ProjectDTO projectDTO = new ProjectDTO(); + projectDTO.setName(req.getName()); + projectDTO.setSource(1); + Result result = projectClient.saveOrUpdate(projectDTO); + logger.info("operational:station:buildStation:"+req.getCode(), JSON.toJSONString(result)); + }).start(); + } @Override public IPage list(StationEntity req, Query query) { @@ -493,4 +541,34 @@ public class StationServiceImpl extends BaseServiceImpl deptResult = sysClient.getDept(stationEntity.getRefDept()); + if(deptResult.isSuccess() && Func.isNotEmpty(deptResult.getData())) { + request = deptResult.getData(); + } + } + request.setStationId(stationEntity.getCode()); + request.setTenantId(AuthUtil.getTenantId()); + request.setFullName(stationEntity.getName()); + request.setDeptName(stationEntity.getName()); + request.setParentId(stationEntity.getHigherDept()); + request.setDeptCategory(StationConstants.DeptCategoryEnum.STATION.getValue()); + request.setSort(1); + R buildResult = deptClient.createOrUpdateDept(request); + if(buildResult.isSuccess()) { + // 所属机构回传 + R deptByStation = sysClient.getDeptByStation(request.getStationId(), AuthUtil.getTenantId()); + stationEntity.setRefDept(Optional.ofNullable(deptByStation).map(R::getData).map(Dept::getId).orElse(null)); + } + return buildResult.isSuccess(); + } + } diff --git a/hzims-service/pom.xml b/hzims-service/pom.xml index 0421103..f4231c0 100644 --- a/hzims-service/pom.xml +++ b/hzims-service/pom.xml @@ -24,7 +24,7 @@ equipment safeproduct operational - inspect + message ticket weather diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/redisConsume/RedisMessageTopic.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/redisConsume/RedisMessageTopic.java new file mode 100644 index 0000000..f5d2fef --- /dev/null +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/redisConsume/RedisMessageTopic.java @@ -0,0 +1,12 @@ +package com.hnac.hzims.ticket.redisConsume; + +/** + * @author hx + * @version 1.0 + * @date 2023/3/14 15:24 + */ +public interface RedisMessageTopic { + + String WORK_TICKET_MESSAGE_KEY = "work::ticket::flow"; + +} diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/redisConsume/WorkTicketMsgConsume.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/redisConsume/WorkTicketMsgConsume.java new file mode 100644 index 0000000..036bbd4 --- /dev/null +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/redisConsume/WorkTicketMsgConsume.java @@ -0,0 +1,27 @@ +package com.hnac.hzims.ticket.redisConsume; + +import com.hnac.hzims.common.config.RedisMessageListener; +import com.hnac.hzims.ticket.twoTicket.service.IFirstWorkTicketService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * @author hx + * @version 1.0 + * @date 2023/3/14 15:12 + */ +@Component +@AllArgsConstructor +@Slf4j +public class WorkTicketMsgConsume { + + private final IFirstWorkTicketService firstWorkTicketService; + + @RedisMessageListener(topic = RedisMessageTopic.WORK_TICKET_MESSAGE_KEY) + public void dealWorkTicketFlow(String message){ + + log.info("接收工作票流程,接收消息为:{}",message); + } + +} diff --git a/hzims-service/weather/pom.xml b/hzims-service/weather/pom.xml index ebbb395..e870b87 100644 --- a/hzims-service/weather/pom.xml +++ b/hzims-service/weather/pom.xml @@ -25,6 +25,13 @@ + + + com.hnac.hzims + hzims-biz-common + ${hzims.project.version} + + org.springblade blade-common diff --git a/hzims-service/weather/src/main/java/com/hnac/hzims/weather/consume/ConsumerMsg.java b/hzims-service/weather/src/main/java/com/hnac/hzims/weather/consume/ConsumerMsg.java new file mode 100644 index 0000000..96d703c --- /dev/null +++ b/hzims-service/weather/src/main/java/com/hnac/hzims/weather/consume/ConsumerMsg.java @@ -0,0 +1,25 @@ +package com.hnac.hzims.weather.consume; + +import com.hnac.hzims.common.config.RedisMessageListener; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; + +/** + * @author hx + * @version 1.0 + * @date 2023/3/12 15:58 + */ +@Service +@Slf4j +public class ConsumerMsg { + @RedisMessageListener(topic = "hzims::weather::test1") + public void receiveMessage1(String message){ + log.info("receiveMessage1收到一条消息:{}",message); + } + + @RedisMessageListener(topic = "hzims::weather::test2") + public void receiveMessage2(String message){ + log.info("receiveMessage2收到一条消息:{}",message); + } +} diff --git a/hzims-service/weather/src/main/java/com/hnac/hzims/weather/supplier/RedisMsgSupplyController.java b/hzims-service/weather/src/main/java/com/hnac/hzims/weather/supplier/RedisMsgSupplyController.java new file mode 100644 index 0000000..dd80c5e --- /dev/null +++ b/hzims-service/weather/src/main/java/com/hnac/hzims/weather/supplier/RedisMsgSupplyController.java @@ -0,0 +1,30 @@ +package com.hnac.hzims.weather.supplier; + +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.R; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author hx + * @version 1.0 + * @date 2023/3/12 16:03 + */ +@RestController +@RequestMapping("/redis/supply") +@AllArgsConstructor +@Slf4j +public class RedisMsgSupplyController { + private final StringRedisTemplate stringRedisTemplate; + + @GetMapping("/test/{channel}/{msg}") + public R test(@PathVariable String channel,@PathVariable String msg) { + stringRedisTemplate.convertAndSend(channel, msg); + return R.success("发送成功"); + } + +} diff --git a/pom.xml b/pom.xml index c467291..63f8297 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,7 @@ 3.8.1 UTF-8 - 4.5.8.RELEASE + 4.6.0-SNAPSHOT