Browse Source

# 安全工器具消息提醒改造

# 视频测试接口调整
zhongwei
haungxing 11 months ago
parent
commit
a3bcd7388d
  1. 5
      hzims-biz-common/src/main/java/com/hnac/hzims/common/constant/CommonConstant.java
  2. 3
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoTypeController.java
  3. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationVideoTypeService.java
  4. 4
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java
  5. 102
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/scheduled/ToolsPushMsgSchedule.java

5
hzims-biz-common/src/main/java/com/hnac/hzims/common/constant/CommonConstant.java

@ -49,4 +49,9 @@ public interface CommonConstant {
*/ */
String DEFAULT_PASSWORD = "123456"; String DEFAULT_PASSWORD = "123456";
/**
* 租户ID
*/
String TENANT_ID = "200000";
} }

3
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) @ApiOperationSupport(order = 140)
@ApiOperation(value = "根据摄像头设备编码获取ws地址", notes = "根据摄像头设备编码获取ws地址") @ApiOperation(value = "根据摄像头设备编码获取ws地址", notes = "根据摄像头设备编码获取ws地址")
public R<Map<String,Object>> getWsUrlByPointCode(@RequestParam(value = "pointCodes",required = false) String pointCodes, public R<Map<String,Object>> getWsUrlByPointCode(@RequestParam(value = "pointCodes",required = false) String pointCodes,
@RequestParam(value = "streamType",required = false) Integer streamType,
@RequestParam(value = "host",required = false) String host, @RequestParam(value = "host",required = false) String host,
@RequestParam(value = "appKey",required = false) String appKey, @RequestParam(value = "appKey",required = false) String appKey,
@RequestParam(value = "appSecret",required = false) String appSecret) { @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));
} }
} }

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationVideoTypeService.java

@ -74,6 +74,6 @@ public interface IStationVideoTypeService extends BaseService<StationVideoTypeEn
* @param pointCodes 摄像头设备编码 * @param pointCodes 摄像头设备编码
* @return ws地址 * @return ws地址
*/ */
Map<String,Object> getWsUrlByPointCode(String pointCodes,String host,String appKey,String appSecret); Map<String,Object> getWsUrlByPointCode(String pointCodes,String host,String appKey,String appSecret,Integer streamType);
} }

4
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java

@ -198,14 +198,14 @@ public class StationVideoTypeServiceImpl extends BaseServiceImpl<StationVideoTyp
} }
@Override @Override
public Map<String, Object> getWsUrlByPointCode(String pointCodes,String host,String appKey,String appSecret) { public Map<String, Object> getWsUrlByPointCode(String pointCodes,String host,String appKey,String appSecret,Integer streamType) {
Map<String,Object> result = new HashMap<>(); Map<String,Object> result = new HashMap<>();
pointCodes = StringUtil.isNotBlank(pointCodes) ? pointCodes : "7eaf556c7d3e429d89cd622256898776,43ee17dafde94c4ba40ad313ebefe6d2,98f51c998acf4dd2951e0484d265710e,6bb1f8ad552444309b68677b8ac3fbaf"; pointCodes = StringUtil.isNotBlank(pointCodes) ? pointCodes : "7eaf556c7d3e429d89cd622256898776,43ee17dafde94c4ba40ad313ebefe6d2,98f51c998acf4dd2951e0484d265710e,6bb1f8ad552444309b68677b8ac3fbaf";
final String finalHost = StringUtil.isNotBlank(host) ? host : videoHost; final String finalHost = StringUtil.isNotBlank(host) ? host : videoHost;
final String finalAppKey = StringUtil.isNotBlank(appKey) ? appKey : videoAppKey; final String finalAppKey = StringUtil.isNotBlank(appKey) ? appKey : videoAppKey;
final String finalAppSecret = StringUtil.isNotBlank(appSecret) ? appSecret : videoAppSecret; final String finalAppSecret = StringUtil.isNotBlank(appSecret) ? appSecret : videoAppSecret;
Map<String,Object> param = new HashMap<String,Object>(6){{ Map<String,Object> param = new HashMap<String,Object>(6){{
put("streamType",0); put("streamType",Func.isNotEmpty(streamType) ? streamType : 0);
put("protocol","ws"); put("protocol","ws");
put("transmode",1); put("transmode",1);
put("expand","transcode=0"); put("expand","transcode=0");

102
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<String> keys = redisTemplate.keys(RedisConstants.TOOLS_REMIND_MSG + "*");
XxlJobLogger.log("===========安全工器具key值为:"+ JSON.toJSONString(keys) +"===========");
keys.forEach(key -> {
Set<SafetyToolEntity> 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<Boolean> 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<String,String>(){{
put("one",safetyTool.getToolName());
put("two",DateUtil.format(safetyTool.getNextCheckTime(),DateUtil.PATTERN_DATE));
}}).build();
R<Boolean> messageResult = messageClient.sendSmsImmediatelyMsg(smsPush);
if(!messageResult.isSuccess()) {
XxlJobLogger.log(safetyTool.getToolCode() + "推送消息失败!");
}
}
}
}
Loading…
Cancel
Save