|
|
|
@ -1,13 +1,14 @@
|
|
|
|
|
package com.hnac.hzims.spare.aspect; |
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Assert; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
import com.google.common.collect.Lists; |
|
|
|
|
import com.hnac.hzims.message.MessageConstants; |
|
|
|
|
import com.hnac.hzims.message.dto.AppPushDto; |
|
|
|
|
import com.hnac.hzims.message.dto.MessagePushRecordDto; |
|
|
|
|
import com.hnac.hzims.message.dto.WsPushDto; |
|
|
|
|
import com.hnac.hzims.message.fegin.IMessageClient; |
|
|
|
|
import com.hnac.hzims.message.fegin.IPushMsgClient; |
|
|
|
|
import com.hnac.hzims.spare.entity.*; |
|
|
|
|
import com.hnac.hzims.spare.service.IWtSpBasicService; |
|
|
|
@ -20,14 +21,16 @@ import org.aspectj.lang.JoinPoint;
|
|
|
|
|
import org.aspectj.lang.annotation.After; |
|
|
|
|
import org.aspectj.lang.annotation.Aspect; |
|
|
|
|
import org.aspectj.lang.annotation.Pointcut; |
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
|
import org.springblade.core.tool.utils.CollectionUtil; |
|
|
|
|
import org.springblade.core.tool.utils.ObjectUtil; |
|
|
|
|
import org.springblade.core.tool.utils.StringUtil; |
|
|
|
|
import org.springblade.system.feign.ISysClient; |
|
|
|
|
import org.springblade.system.user.cache.UserCache; |
|
|
|
|
import org.springblade.system.user.entity.User; |
|
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
|
|
import java.lang.reflect.Field; |
|
|
|
|
import java.util.Arrays; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.concurrent.*; |
|
|
|
|
|
|
|
|
@ -40,156 +43,236 @@ import java.util.concurrent.*;
|
|
|
|
|
@AllArgsConstructor |
|
|
|
|
public class LimitRemindAspect { |
|
|
|
|
|
|
|
|
|
private final IPushMsgClient pushMsgClient; |
|
|
|
|
private final IWtSpWarehouseService wtSpWarehouseService; |
|
|
|
|
private final IWtSpTotalService wtSpTotalService; |
|
|
|
|
private final IWtSpBasicService wtSpBasicService; |
|
|
|
|
private final IPushMsgClient pushMsgClient; |
|
|
|
|
private final IWtSpWarehouseService wtSpWarehouseService; |
|
|
|
|
private final IWtSpTotalService wtSpTotalService; |
|
|
|
|
private final IWtSpBasicService wtSpBasicService; |
|
|
|
|
private final ISysClient sysClient; |
|
|
|
|
private final IMessageClient messageClient; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 以出入库保存方法为切点 处理预警信息(暂未考虑台账上下限变化因素) |
|
|
|
|
*/ |
|
|
|
|
@Pointcut("execution(* com.hnac.hzims.spare.service.impl.SpWarehouseInServiceImpl.save(..)) " + |
|
|
|
|
"|| execution(* com.hnac.hzims.spare.service.impl.SpWarehouseOutServiceImpl.save(..))") |
|
|
|
|
public void warnPointCut() { |
|
|
|
|
/** |
|
|
|
|
* 以出入库保存方法为切点 处理预警信息(暂未考虑台账上下限变化因素) |
|
|
|
|
*/ |
|
|
|
|
@Pointcut("execution(* com.hnac.hzims.spare.service.impl.SpWarehouseInServiceImpl.save(..)) " + |
|
|
|
|
"|| execution(* com.hnac.hzims.spare.service.impl.SpWarehouseOutServiceImpl.save(..))") |
|
|
|
|
public void warnPointCut() { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
* 生成预警后进行消息提醒 |
|
|
|
|
* @param point 连接点 |
|
|
|
|
*/ |
|
|
|
|
@After("warnPointCut()") |
|
|
|
|
public void after(JoinPoint point) { |
|
|
|
|
Object[] args = point.getArgs(); |
|
|
|
|
if(args.length == 1 && (args[0] instanceof SpWarehouseInEntity || args[0] instanceof SpWarehouseOutEntity)){ |
|
|
|
|
log.info("===进入库存预警消息推送==="); |
|
|
|
|
Field basicListField = null; |
|
|
|
|
Field warehouseIdField = null; |
|
|
|
|
try { |
|
|
|
|
basicListField = args[0].getClass().getDeclaredField("basicList"); |
|
|
|
|
warehouseIdField = args[0].getClass().getDeclaredField("storageRoom"); |
|
|
|
|
basicListField.setAccessible(true); |
|
|
|
|
warehouseIdField.setAccessible(true); |
|
|
|
|
Assert.notNull(basicListField,"获取basicList属性失败"); |
|
|
|
|
Assert.notNull(warehouseIdField,"获取storageRoom属性失败"); |
|
|
|
|
} catch (NoSuchFieldException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
List<SpRecordEntity> basicList = null; |
|
|
|
|
Long warehouseId = null; |
|
|
|
|
try { |
|
|
|
|
basicList = (List<SpRecordEntity>) basicListField.get(args[0]); |
|
|
|
|
warehouseId = (Long) warehouseIdField.get(args[0]); |
|
|
|
|
if(CollectionUtil.isNotEmpty(basicList) && ObjectUtil.isNotEmpty(warehouseId)){ |
|
|
|
|
this.pushWarehouseWarning(warehouseId,basicList); |
|
|
|
|
} |
|
|
|
|
} catch (IllegalAccessException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
log.info("===库存预警消息推送结束==="); |
|
|
|
|
} |
|
|
|
|
/*** |
|
|
|
|
* 生成预警后进行消息提醒 |
|
|
|
|
* @param point 连接点 |
|
|
|
|
*/ |
|
|
|
|
@After("warnPointCut()") |
|
|
|
|
public void after(JoinPoint point) { |
|
|
|
|
Object[] args = point.getArgs(); |
|
|
|
|
if (args.length == 1 && (args[0] instanceof SpWarehouseInEntity || args[0] instanceof SpWarehouseOutEntity)) { |
|
|
|
|
log.info("===进入库存预警消息推送==="); |
|
|
|
|
Field basicListField = null; |
|
|
|
|
Field warehouseIdField = null; |
|
|
|
|
try { |
|
|
|
|
basicListField = args[0].getClass().getDeclaredField("basicList"); |
|
|
|
|
warehouseIdField = args[0].getClass().getDeclaredField("storageRoom"); |
|
|
|
|
basicListField.setAccessible(true); |
|
|
|
|
warehouseIdField.setAccessible(true); |
|
|
|
|
Assert.notNull(basicListField, "获取basicList属性失败"); |
|
|
|
|
Assert.notNull(warehouseIdField, "获取storageRoom属性失败"); |
|
|
|
|
} catch (NoSuchFieldException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
List<SpRecordEntity> basicList = null; |
|
|
|
|
Long warehouseId = null; |
|
|
|
|
try { |
|
|
|
|
basicList = (List<SpRecordEntity>) basicListField.get(args[0]); |
|
|
|
|
warehouseId = (Long) warehouseIdField.get(args[0]); |
|
|
|
|
if (CollectionUtil.isNotEmpty(basicList) && ObjectUtil.isNotEmpty(warehouseId)) { |
|
|
|
|
this.pushWarehouseWarningV2(warehouseId, basicList); |
|
|
|
|
} |
|
|
|
|
} catch (IllegalAccessException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
log.info("===库存预警消息推送结束==="); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 查询出入库备品备件是否存在告警信息并推送 |
|
|
|
|
* @param spRecordEntityList 出入库备品备件列表 |
|
|
|
|
* @param warehouseId 仓库ID |
|
|
|
|
*/ |
|
|
|
|
private void pushWarehouseWarning(Long warehouseId, List<SpRecordEntity> spRecordEntityList){ |
|
|
|
|
//开启线程池推送消息
|
|
|
|
|
ExecutorService executorService = new ThreadPoolExecutor(1,1,1, TimeUnit.SECONDS,new LinkedBlockingDeque<>()); |
|
|
|
|
executorService.execute(()-> spRecordEntityList.forEach(spRecordEntity -> { |
|
|
|
|
//查询该仓库是否有备品备件超出上下限
|
|
|
|
|
WtSpWarehouseEntity wtSpWarehouseEntity = wtSpWarehouseService.selectById(warehouseId); |
|
|
|
|
WtSpTotalEntity wtSpTotalEntity = wtSpTotalService.getOne(Wrappers.<WtSpTotalEntity>lambdaQuery() |
|
|
|
|
.eq(WtSpTotalEntity::getSpBasicId,spRecordEntity.getSpBasicId()) |
|
|
|
|
.eq(WtSpTotalEntity::getWarehouseId,warehouseId) |
|
|
|
|
.last("limit 1;") |
|
|
|
|
); |
|
|
|
|
WtSpBasicEntity basicEntity = wtSpBasicService.getById(spRecordEntity.getSpBasicId()); |
|
|
|
|
//超出上限/下限发送消息提醒
|
|
|
|
|
log.info("仓库id为:{},库存为:{},上限为:{},下限为:{}",warehouseId,wtSpTotalEntity.getStock(),basicEntity.getUpperLimit(),basicEntity.getLowerLimit()); |
|
|
|
|
if(wtSpTotalEntity.getStock() > basicEntity.getUpperLimit() || wtSpTotalEntity.getStock() < basicEntity.getLowerLimit()) { |
|
|
|
|
User pusher = UserCache.getUser(wtSpWarehouseEntity.getManager()); |
|
|
|
|
if(ObjectUtil.isEmpty(pusher)){ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
//完善推送信息
|
|
|
|
|
String alert; |
|
|
|
|
if(wtSpTotalEntity.getStock() > basicEntity.getUpperLimit()) { |
|
|
|
|
alert = String.format("%s内的(%s)已达到上限,目前仓库内的库存为:%s,上限值为:%s。请及时处理!", |
|
|
|
|
wtSpWarehouseEntity.getName(), |
|
|
|
|
basicEntity.getName(), |
|
|
|
|
wtSpTotalEntity.getStock(), |
|
|
|
|
basicEntity.getUpperLimit() |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
alert = String.format("%s内的(%s)已达到下限,目前仓库内的库存为:%s,下限值为:%s。请及时处理!", |
|
|
|
|
wtSpWarehouseEntity.getName(), |
|
|
|
|
basicEntity.getName(), |
|
|
|
|
wtSpTotalEntity.getStock(), |
|
|
|
|
basicEntity.getLowerLimit() |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
//推送web消息
|
|
|
|
|
CompletableFuture.supplyAsync(()->{ |
|
|
|
|
this.warningPushWeb(alert,pusher); |
|
|
|
|
return "推送成功"; |
|
|
|
|
}); |
|
|
|
|
//推送App消息
|
|
|
|
|
CompletableFuture.supplyAsync(()->{ |
|
|
|
|
this.warningPushApp(alert,pusher); |
|
|
|
|
return "推送成功"; |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
})); |
|
|
|
|
executorService.shutdown(); |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* 查询出入库备品备件是否存在告警信息并推送 |
|
|
|
|
* |
|
|
|
|
* @param spRecordEntityList 出入库备品备件列表 |
|
|
|
|
* @param warehouseId 仓库ID |
|
|
|
|
*/ |
|
|
|
|
final static ExecutorService executorService = new ThreadPoolExecutor(5, 5, 1, TimeUnit.SECONDS, new LinkedBlockingDeque<>()); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 备品备件-预警app推送 |
|
|
|
|
* @param alert 推送内容 |
|
|
|
|
* @param pusher 推送人 |
|
|
|
|
*/ |
|
|
|
|
private void warningPushApp(String alert, User pusher) { |
|
|
|
|
//app推送
|
|
|
|
|
AppPushDto appPushDto = new AppPushDto(); |
|
|
|
|
appPushDto.setBusinessClassify(MessageConstants.BusinessClassifyEnum.ASSETS.getKey()); |
|
|
|
|
appPushDto.setBusinessKey("assets-warning"); |
|
|
|
|
appPushDto.setIsAll(true); |
|
|
|
|
appPushDto.setContent(alert); |
|
|
|
|
appPushDto.setSubject("库存预警"); |
|
|
|
|
appPushDto.setTitle("库存预警"); |
|
|
|
|
appPushDto.setAudienceType(PushAudienceType.TAG); |
|
|
|
|
appPushDto.setTags(Lists.newArrayList(new String[]{pusher.getId().toString()})); |
|
|
|
|
//FIXME 因feign接口请求头丢失 登录信息失效先启用未登陆方式
|
|
|
|
|
appPushDto.setTenantId("200000"); |
|
|
|
|
appPushDto.setCreateUser(1380746947515691009L); |
|
|
|
|
appPushDto.setCreateDept(2000000101L); |
|
|
|
|
appPushDto.setPushAlert(alert); |
|
|
|
|
pushMsgClient.sendPush(appPushDto); |
|
|
|
|
} |
|
|
|
|
private void pushWarehouseWarningV2(Long warehouseId, List<SpRecordEntity> spRecordEntityList) { |
|
|
|
|
//开启线程池推送消息
|
|
|
|
|
executorService.execute(() -> spRecordEntityList.forEach(spRecordEntity -> { |
|
|
|
|
//查询该仓库是否有备品备件超出上下限
|
|
|
|
|
WtSpWarehouseEntity wtSpWarehouseEntity = wtSpWarehouseService.selectById(warehouseId); |
|
|
|
|
WtSpTotalEntity wtSpTotalEntity = wtSpTotalService.getOne(Wrappers.<WtSpTotalEntity>lambdaQuery() |
|
|
|
|
.eq(WtSpTotalEntity::getSpBasicId, spRecordEntity.getSpBasicId()) |
|
|
|
|
.eq(WtSpTotalEntity::getWarehouseId, warehouseId) |
|
|
|
|
.last("limit 1;") |
|
|
|
|
); |
|
|
|
|
WtSpBasicEntity basicEntity = wtSpBasicService.getById(spRecordEntity.getSpBasicId()); |
|
|
|
|
//超出上限/下限发送消息提醒
|
|
|
|
|
log.info("仓库id为:{},库存为:{},上限为:{},下限为:{}", warehouseId, wtSpTotalEntity.getStock(), basicEntity.getUpperLimit(), basicEntity.getLowerLimit()); |
|
|
|
|
if (wtSpTotalEntity.getStock() > basicEntity.getUpperLimit() || wtSpTotalEntity.getStock() < basicEntity.getLowerLimit()) { |
|
|
|
|
User pusher = UserCache.getUser(wtSpWarehouseEntity.getManager()); |
|
|
|
|
if (ObjectUtil.isEmpty(pusher)) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
//完善推送信息
|
|
|
|
|
String alert; |
|
|
|
|
if (wtSpTotalEntity.getStock() > basicEntity.getUpperLimit()) { |
|
|
|
|
alert = String.format("%s内的(%s)已达到上限,目前仓库内的库存为:%s,上限值为:%s。请及时处理!", |
|
|
|
|
wtSpWarehouseEntity.getName(), |
|
|
|
|
basicEntity.getName(), |
|
|
|
|
wtSpTotalEntity.getStock(), |
|
|
|
|
basicEntity.getUpperLimit() |
|
|
|
|
); |
|
|
|
|
} else { |
|
|
|
|
alert = String.format("%s内的(%s)已达到下限,目前仓库内的库存为:%s,下限值为:%s。请及时处理!", |
|
|
|
|
wtSpWarehouseEntity.getName(), |
|
|
|
|
basicEntity.getName(), |
|
|
|
|
wtSpTotalEntity.getStock(), |
|
|
|
|
basicEntity.getLowerLimit() |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
//推送消息
|
|
|
|
|
CompletableFuture.supplyAsync(() -> { |
|
|
|
|
this.warningPush(alert, pusher,warehouseId); |
|
|
|
|
return "推送成功"; |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
})); |
|
|
|
|
executorService.shutdown(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 备品备件-预警web推送 |
|
|
|
|
* @param alert 推送内容 |
|
|
|
|
* @param pusher 推送人 |
|
|
|
|
*/ |
|
|
|
|
private void warningPushWeb(String alert, User pusher) { |
|
|
|
|
//web推送
|
|
|
|
|
WsPushDto wsPushDto = new WsPushDto(); |
|
|
|
|
wsPushDto.setBusinessClassify(MessageConstants.BusinessClassifyEnum.ASSETS.getKey()); |
|
|
|
|
wsPushDto.setBusinessKey("assets-warning"); |
|
|
|
|
wsPushDto.setContent(alert); |
|
|
|
|
wsPushDto.setSubject("库存预警"); |
|
|
|
|
wsPushDto.setSubject("备品备件预警信息"); |
|
|
|
|
wsPushDto.setUserIdList(Lists.newArrayList(new String[]{pusher.getId().toString()})); |
|
|
|
|
wsPushDto.setText(alert); |
|
|
|
|
//FIXME 因feign接口请求头丢失 登录信息失效先启用未登陆方式
|
|
|
|
|
wsPushDto.setTenantId("200000"); |
|
|
|
|
wsPushDto.setCreateUser(1380746947515691009L); |
|
|
|
|
wsPushDto.setCreateDept(2000000101L); |
|
|
|
|
pushMsgClient.sendWebsocket(wsPushDto); |
|
|
|
|
} |
|
|
|
|
private void warningPush(String alert, User pusher,Long warehouseId) { |
|
|
|
|
MessagePushRecordDto message = new MessagePushRecordDto(); |
|
|
|
|
message.setBusinessClassify("business"); |
|
|
|
|
message.setBusinessKey(MessageConstants.BusinessClassifyEnum.ASSETS.getKey()); |
|
|
|
|
message.setSubject(MessageConstants.BusinessClassifyEnum.ASSETS.getDescription()); |
|
|
|
|
message.setTaskId(warehouseId); |
|
|
|
|
message.setTenantId("200000"); |
|
|
|
|
message.setTypes(Arrays.asList(MessageConstants.APP_PUSH, MessageConstants.WS_PUSH)); |
|
|
|
|
message.setPushType(MessageConstants.IMMEDIATELY); |
|
|
|
|
message.setContent(alert); |
|
|
|
|
message.setDeptId(pusher.getCreateDept()); |
|
|
|
|
R<String> deptName = sysClient.getDeptName(pusher.getCreateDept()); |
|
|
|
|
if (deptName.isSuccess()) { |
|
|
|
|
message.setDeptName(deptName.getData()); |
|
|
|
|
} |
|
|
|
|
Long userId = pusher.getId(); |
|
|
|
|
if (ObjectUtils.isEmpty(userId)) { |
|
|
|
|
log.error("推送人不能为空哦,{}", userId); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
message.setPusher(userId.toString()); |
|
|
|
|
message.setPusherName(pusher.getName()); |
|
|
|
|
message.setAccount(pusher.getAccount()); |
|
|
|
|
message.setCreateUser(userId); |
|
|
|
|
messageClient.sendMessage(message); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//此接口已经弃用20230608
|
|
|
|
|
@Deprecated |
|
|
|
|
private void pushWarehouseWarning(Long warehouseId, List<SpRecordEntity> spRecordEntityList) { |
|
|
|
|
//开启线程池推送消息
|
|
|
|
|
executorService.execute(() -> spRecordEntityList.forEach(spRecordEntity -> { |
|
|
|
|
//查询该仓库是否有备品备件超出上下限
|
|
|
|
|
WtSpWarehouseEntity wtSpWarehouseEntity = wtSpWarehouseService.selectById(warehouseId); |
|
|
|
|
WtSpTotalEntity wtSpTotalEntity = wtSpTotalService.getOne(Wrappers.<WtSpTotalEntity>lambdaQuery() |
|
|
|
|
.eq(WtSpTotalEntity::getSpBasicId, spRecordEntity.getSpBasicId()) |
|
|
|
|
.eq(WtSpTotalEntity::getWarehouseId, warehouseId) |
|
|
|
|
.last("limit 1;") |
|
|
|
|
); |
|
|
|
|
WtSpBasicEntity basicEntity = wtSpBasicService.getById(spRecordEntity.getSpBasicId()); |
|
|
|
|
//超出上限/下限发送消息提醒
|
|
|
|
|
log.info("仓库id为:{},库存为:{},上限为:{},下限为:{}", warehouseId, wtSpTotalEntity.getStock(), basicEntity.getUpperLimit(), basicEntity.getLowerLimit()); |
|
|
|
|
if (wtSpTotalEntity.getStock() > basicEntity.getUpperLimit() || wtSpTotalEntity.getStock() < basicEntity.getLowerLimit()) { |
|
|
|
|
User pusher = UserCache.getUser(wtSpWarehouseEntity.getManager()); |
|
|
|
|
if (ObjectUtil.isEmpty(pusher)) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
//完善推送信息
|
|
|
|
|
String alert; |
|
|
|
|
if (wtSpTotalEntity.getStock() > basicEntity.getUpperLimit()) { |
|
|
|
|
alert = String.format("%s内的(%s)已达到上限,目前仓库内的库存为:%s,上限值为:%s。请及时处理!", |
|
|
|
|
wtSpWarehouseEntity.getName(), |
|
|
|
|
basicEntity.getName(), |
|
|
|
|
wtSpTotalEntity.getStock(), |
|
|
|
|
basicEntity.getUpperLimit() |
|
|
|
|
); |
|
|
|
|
} else { |
|
|
|
|
alert = String.format("%s内的(%s)已达到下限,目前仓库内的库存为:%s,下限值为:%s。请及时处理!", |
|
|
|
|
wtSpWarehouseEntity.getName(), |
|
|
|
|
basicEntity.getName(), |
|
|
|
|
wtSpTotalEntity.getStock(), |
|
|
|
|
basicEntity.getLowerLimit() |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
//推送web消息
|
|
|
|
|
CompletableFuture.supplyAsync(() -> { |
|
|
|
|
this.warningPushWeb(alert, pusher); |
|
|
|
|
return "推送成功"; |
|
|
|
|
}); |
|
|
|
|
//推送App消息
|
|
|
|
|
CompletableFuture.supplyAsync(() -> { |
|
|
|
|
this.warningPushApp(alert, pusher); |
|
|
|
|
return "推送成功"; |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
})); |
|
|
|
|
executorService.shutdown(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 备品备件-预警app推送 |
|
|
|
|
* |
|
|
|
|
* @param alert 推送内容 |
|
|
|
|
* @param pusher 推送人 |
|
|
|
|
*/ |
|
|
|
|
private void warningPushApp(String alert, User pusher) { |
|
|
|
|
//app推送
|
|
|
|
|
AppPushDto appPushDto = new AppPushDto(); |
|
|
|
|
appPushDto.setBusinessClassify(MessageConstants.BusinessClassifyEnum.ASSETS.getKey()); |
|
|
|
|
appPushDto.setBusinessKey("assets-warning"); |
|
|
|
|
appPushDto.setIsAll(true); |
|
|
|
|
appPushDto.setContent(alert); |
|
|
|
|
appPushDto.setSubject("库存预警"); |
|
|
|
|
appPushDto.setTitle("库存预警"); |
|
|
|
|
appPushDto.setAudienceType(PushAudienceType.TAG); |
|
|
|
|
appPushDto.setTags(Lists.newArrayList(new String[]{pusher.getId().toString()})); |
|
|
|
|
//FIXME 因feign接口请求头丢失 登录信息失效先启用未登陆方式
|
|
|
|
|
appPushDto.setTenantId("200000"); |
|
|
|
|
appPushDto.setCreateUser(1380746947515691009L); |
|
|
|
|
appPushDto.setCreateDept(2000000101L); |
|
|
|
|
appPushDto.setPushAlert(alert); |
|
|
|
|
pushMsgClient.sendPush(appPushDto); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 备品备件-预警web推送 |
|
|
|
|
* |
|
|
|
|
* @param alert 推送内容 |
|
|
|
|
* @param pusher 推送人 |
|
|
|
|
*/ |
|
|
|
|
private void warningPushWeb(String alert, User pusher) { |
|
|
|
|
//web推送
|
|
|
|
|
WsPushDto wsPushDto = new WsPushDto(); |
|
|
|
|
wsPushDto.setBusinessClassify(MessageConstants.BusinessClassifyEnum.ASSETS.getKey()); |
|
|
|
|
wsPushDto.setBusinessKey("assets-warning"); |
|
|
|
|
wsPushDto.setContent(alert); |
|
|
|
|
wsPushDto.setSubject("库存预警"); |
|
|
|
|
wsPushDto.setSubject("备品备件预警信息"); |
|
|
|
|
wsPushDto.setUserIdList(Lists.newArrayList(new String[]{pusher.getId().toString()})); |
|
|
|
|
wsPushDto.setText(alert); |
|
|
|
|
//FIXME 因feign接口请求头丢失 登录信息失效先启用未登陆方式
|
|
|
|
|
wsPushDto.setTenantId("200000"); |
|
|
|
|
wsPushDto.setCreateUser(1380746947515691009L); |
|
|
|
|
wsPushDto.setCreateDept(2000000101L); |
|
|
|
|
pushMsgClient.sendWebsocket(wsPushDto); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|