diff --git a/hzims-biz-common/src/main/java/com/hnac/hzims/common/constant/CommonConstant.java b/hzims-biz-common/src/main/java/com/hnac/hzims/common/constant/CommonConstant.java index 31abfa1..801f766 100644 --- a/hzims-biz-common/src/main/java/com/hnac/hzims/common/constant/CommonConstant.java +++ b/hzims-biz-common/src/main/java/com/hnac/hzims/common/constant/CommonConstant.java @@ -49,4 +49,9 @@ public interface CommonConstant { */ String DEFAULT_PASSWORD = "123456"; + /** + * 租户ID + */ + String TENANT_ID = "200000"; + } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoTypeController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoTypeController.java index e1cac85..981ab67 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoTypeController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoTypeController.java @@ -305,10 +305,11 @@ public class StationVideoTypeController extends BladeController { @ApiOperationSupport(order = 140) @ApiOperation(value = "根据摄像头设备编码获取ws地址", notes = "根据摄像头设备编码获取ws地址") public R> getWsUrlByPointCode(@RequestParam(value = "pointCodes",required = false) String pointCodes, + @RequestParam(value = "streamType",required = false) Integer streamType, @RequestParam(value = "host",required = false) String host, @RequestParam(value = "appKey",required = false) String appKey, @RequestParam(value = "appSecret",required = false) String appSecret) { - return R.data(stationVideoTypeService.getWsUrlByPointCode(pointCodes,host,appKey,appSecret)); + return R.data(stationVideoTypeService.getWsUrlByPointCode(pointCodes,host,appKey,appSecret,streamType)); } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationVideoTypeService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationVideoTypeService.java index 01d55b1..834a7e3 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationVideoTypeService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationVideoTypeService.java @@ -74,6 +74,6 @@ public interface IStationVideoTypeService extends BaseService getWsUrlByPointCode(String pointCodes,String host,String appKey,String appSecret); + Map getWsUrlByPointCode(String pointCodes,String host,String appKey,String appSecret,Integer streamType); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java index b4ffcce..f3500bb 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java @@ -198,14 +198,14 @@ public class StationVideoTypeServiceImpl extends BaseServiceImpl getWsUrlByPointCode(String pointCodes,String host,String appKey,String appSecret) { + public Map getWsUrlByPointCode(String pointCodes,String host,String appKey,String appSecret,Integer streamType) { Map result = new HashMap<>(); pointCodes = StringUtil.isNotBlank(pointCodes) ? pointCodes : "7eaf556c7d3e429d89cd622256898776,43ee17dafde94c4ba40ad313ebefe6d2,98f51c998acf4dd2951e0484d265710e,6bb1f8ad552444309b68677b8ac3fbaf"; final String finalHost = StringUtil.isNotBlank(host) ? host : videoHost; final String finalAppKey = StringUtil.isNotBlank(appKey) ? appKey : videoAppKey; final String finalAppSecret = StringUtil.isNotBlank(appSecret) ? appSecret : videoAppSecret; Map param = new HashMap(6){{ - put("streamType",0); + put("streamType",Func.isNotEmpty(streamType) ? streamType : 0); put("protocol","ws"); put("transmode",1); put("expand","transcode=0"); diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/scheduled/ToolsPushMsgSchedule.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/scheduled/ToolsPushMsgSchedule.java new file mode 100644 index 0000000..4514c1b --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/scheduled/ToolsPushMsgSchedule.java @@ -0,0 +1,102 @@ +package com.hnac.hzims.safeproduct.scheduled; + +import com.alibaba.fastjson.JSON; +import com.hnac.hzims.common.constant.CommonConstant; +import com.hnac.hzims.message.MessageConstants; +import com.hnac.hzims.message.dto.BusinessMessageDTO; +import com.hnac.hzims.message.dto.SmsImmediatelyPushDTO; +import com.hnac.hzims.message.fegin.IMessageClient; +import com.hnac.hzims.safeproduct.constants.RedisConstants; +import com.hnac.hzims.safeproduct.entity.SafetyToolEntity; +import com.hnac.hzims.safeproduct.service.ISafetyToolService; +import com.xxl.job.core.biz.model.ReturnT; +import com.xxl.job.core.handler.annotation.XxlJob; +import com.xxl.job.core.log.XxlJobLogger; +import lombok.AllArgsConstructor; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.DateUtil; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Component; + +import java.util.Date; +import java.util.HashMap; +import java.util.Set; + +@Component +@Slf4j +@RequiredArgsConstructor +public class ToolsPushMsgSchedule { + + private final ISafetyToolService toolService; + private final RedisTemplate redisTemplate; + private final IMessageClient messageClient; + + @Value("${hzims.safeProduct.safeTool.sms-code}") + private String smsCode; + + @XxlJob("toolsPushMessage") + public ReturnT execute(String params) { + Set keys = redisTemplate.keys(RedisConstants.TOOLS_REMIND_MSG + "*"); + XxlJobLogger.log("===========安全工器具key值为:"+ JSON.toJSONString(keys) +"==========="); + keys.forEach(key -> { + Set toolList = redisTemplate.opsForZSet().reverseRangeByScore(key, 0, new Date().getTime()); + toolList.forEach(tool -> { + SafetyToolEntity safetyTool = toolService.getById(tool.getId()); + // 安全工器具推送消息 + this.pushMessageByTool(safetyTool); + }); + redisTemplate.opsForZSet().remove(key,toolList.toArray()); + }); + return ReturnT.SUCCESS; + } + + /** + * 推送安全工器具消息 + * @param safetyTool 安全工器具实体类 + */ + private void pushMessageByTool(SafetyToolEntity safetyTool) { + String alert = "工器具检查提醒:工器具("+safetyTool.getToolName()+")将于"+ DateUtil.format(safetyTool.getNextCheckTime(),DateUtil.PATTERN_DATE)+"到检查时间,请安排时间复核!"; + // APP推送 + if(SafeToolTypePushUserTask.JG_PUSH == safetyTool.getSendType()) { + BusinessMessageDTO request = new BusinessMessageDTO(); + request.setTenantId(CommonConstant.TENANT_ID); + request.setDeptId(safetyTool.getCreateDept()); + request.setBusinessKey("安全工器具提醒"); + request.setBusinessClassify(MessageConstants.BusinessClassifyEnum.SAFE_PRODUCT.getKey()); + request.setTaskId(safetyTool.getId()); + request.setContent(alert); + request.setSubject("安全工器具复核时间到期提醒"); + request.setUserIds(safetyTool.getNoticeUsers()); + request.setCreateUser(safetyTool.getCreateUser()); + R messageResult = messageClient.sendAppAndWsMsgByUsers(request); + if(!messageResult.isSuccess()) { + XxlJobLogger.log(safetyTool.getToolCode() + "推送消息失败!"); + } + } + // 短信推送 + else if(SafeToolTypePushUserTask.APP_PUSH == safetyTool.getSendType()) { + SmsImmediatelyPushDTO smsPush = SmsImmediatelyPushDTO.builder() + .deptId(safetyTool.getCreateDept()) + .taskId(safetyTool.getId()) + .businessKey("安全工器具提醒") + .businessClassify(MessageConstants.BusinessClassifyEnum.SAFE_PRODUCT.getKey()) + .content(alert) + .subject("安全工器具复核时间到期提醒") + .pusher(safetyTool.getNoticeUsers()) + .createUser(safetyTool.getCreateUser()) + .tenantId(CommonConstant.TENANT_ID) + .resourceCode(smsCode) + .params(new HashMap(){{ + put("one",safetyTool.getToolName()); + put("two",DateUtil.format(safetyTool.getNextCheckTime(),DateUtil.PATTERN_DATE)); + }}).build(); + R messageResult = messageClient.sendSmsImmediatelyMsg(smsPush); + if(!messageResult.isSuccess()) { + XxlJobLogger.log(safetyTool.getToolCode() + "推送消息失败!"); + } + } + } +}