|
@@ -9,16 +9,23 @@ import cn.com.ty.lift.business.maintenance.service.MaintenancePlanService;
|
|
|
import cn.com.ty.lift.business.maintenance.service.MaintenanceService;
|
|
|
import cn.com.ty.lift.business.project.dao.entity.Project;
|
|
|
import cn.com.ty.lift.business.project.dao.entity.ProjectLiftRelevance;
|
|
|
+import cn.com.ty.lift.business.project.dao.entity.Region;
|
|
|
import cn.com.ty.lift.business.project.dao.entity.model.request.ProjectRequest;
|
|
|
-import cn.com.ty.lift.business.project.dao.mapper.ProjectMapper;
|
|
|
+import cn.com.ty.lift.business.project.dao.entity.model.response.ProjectDetailResponse;
|
|
|
+import cn.com.ty.lift.business.project.service.ProjectAppService;
|
|
|
import cn.com.ty.lift.business.project.service.ProjectLiftRelevanceService;
|
|
|
import cn.com.ty.lift.business.project.service.ProjectService;
|
|
|
+import cn.com.ty.lift.business.push.service.PushUserService;
|
|
|
import cn.com.ty.lift.common.constants.CommonEnum;
|
|
|
+import cn.com.ty.lift.common.model.PushMessage;
|
|
|
+import cn.com.ty.lift.common.model.PushUserInfo;
|
|
|
+import cn.com.ty.lift.common.utils.SendMessageUtil;
|
|
|
import cn.com.xwy.boot.web.dto.RestResponse;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import org.springframework.jms.core.JmsMessagingTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
@@ -50,6 +57,15 @@ public class PlatformCompanyLiftRelevanceService extends ServiceImpl<PlatformCom
|
|
|
@Resource
|
|
|
private ProjectService projectService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private JmsMessagingTemplate jmsMessagingTemplate;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private PushUserService pushUserService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ProjectAppService projectAppService;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* @param id 电梯id
|
|
@@ -159,6 +175,66 @@ public class PlatformCompanyLiftRelevanceService extends ServiceImpl<PlatformCom
|
|
|
return baseMapper.selectBatchIds(list);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @param projectId 项目ID
|
|
|
+ * @param mtCompanyId 公司ID
|
|
|
+ * @return
|
|
|
+ * @description 停止服务消息推送
|
|
|
+ * @date 2020/5/5 9:26 下午
|
|
|
+ */
|
|
|
+ public void sendStopMessage(Long projectId, Long mtCompanyId) {
|
|
|
+ //消息推送
|
|
|
+ List<Long> userIds = new ArrayList<>();
|
|
|
+ Region region = pushUserService.findRegionByProject(projectId, mtCompanyId);
|
|
|
+ if (Objects.nonNull(region)) {
|
|
|
+ userIds.addAll(region.members());
|
|
|
+ }
|
|
|
+ List<PushUserInfo> director = pushUserService.listEnterpriseAdmin(mtCompanyId);
|
|
|
+ List<PushUserInfo> pushUserInfos = new ArrayList<>(director);
|
|
|
+ if (!userIds.isEmpty()) {
|
|
|
+ List<PushUserInfo> userInfos = pushUserService.listByUserIds(mtCompanyId, userIds);
|
|
|
+ pushUserInfos.addAll(userInfos);
|
|
|
+ }
|
|
|
+ if (!pushUserInfos.isEmpty()) {
|
|
|
+ ProjectDetailResponse detail = projectAppService.detail(projectId);
|
|
|
+ PushMessage pushMessage = PushMessage.workProjectStopService(detail.getAreaName(), detail.getProjectName(), detail.getNum());
|
|
|
+ pushMessage.sendTokenOnPlatform(jmsMessagingTemplate, pushUserInfos);
|
|
|
+ List<Long> sendToUserIdList = pushUserInfos.stream().map(PushUserInfo::getUserId).collect(Collectors.toList());
|
|
|
+ //推送pc端
|
|
|
+ SendMessageUtil.sendMessageToPC(jmsMessagingTemplate, sendToUserIdList, pushMessage.getContent());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param projectId 项目ID
|
|
|
+ * @param mtCompanyId 公司ID
|
|
|
+ * @return
|
|
|
+ * @description 恢复服务消息推送
|
|
|
+ * @date 2020/5/5 9:26 下午
|
|
|
+ */
|
|
|
+ public void sendRecoverMessage(Long projectId, Long mtCompanyId) {
|
|
|
+ //消息推送
|
|
|
+ List<Long> userIds = new ArrayList<>();
|
|
|
+ Region region = pushUserService.findRegionByProject(projectId, mtCompanyId);
|
|
|
+ if (Objects.nonNull(region)) {
|
|
|
+ userIds.addAll(region.members());
|
|
|
+ }
|
|
|
+ List<PushUserInfo> director = pushUserService.listEnterpriseAdmin(mtCompanyId);
|
|
|
+ List<PushUserInfo> pushUserInfos = new ArrayList<>(director);
|
|
|
+ if (!userIds.isEmpty()) {
|
|
|
+ List<PushUserInfo> userInfos = pushUserService.listByUserIds(mtCompanyId, userIds);
|
|
|
+ pushUserInfos.addAll(userInfos);
|
|
|
+ }
|
|
|
+ if (!pushUserInfos.isEmpty()) {
|
|
|
+ ProjectDetailResponse detail = projectAppService.detail(projectId);
|
|
|
+ PushMessage pushMessage = PushMessage.workProjectRecoverService(detail.getAreaName(), detail.getProjectName());
|
|
|
+ pushMessage.sendTokenOnPlatform(jmsMessagingTemplate, pushUserInfos);
|
|
|
+ List<Long> sendToUserIdList = pushUserInfos.stream().map(PushUserInfo::getUserId).collect(Collectors.toList());
|
|
|
+ //推送pc端
|
|
|
+ SendMessageUtil.sendMessageToPC(jmsMessagingTemplate, sendToUserIdList, pushMessage.getContent());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param request liftIdList 电梯id列表
|
|
|
* @return 1.成功, 0.失败, 消息描述
|
|
@@ -196,6 +272,8 @@ public class PlatformCompanyLiftRelevanceService extends ServiceImpl<PlatformCom
|
|
|
return RestResponse.fail(MessageUtils.get("msg.modify.batch.fail"));
|
|
|
}
|
|
|
}
|
|
|
+ //恢复服务发送消息
|
|
|
+ sendRecoverMessage(projectId, mtCompanyId);
|
|
|
break;
|
|
|
//停止服务
|
|
|
case 2:
|
|
@@ -207,6 +285,8 @@ public class PlatformCompanyLiftRelevanceService extends ServiceImpl<PlatformCom
|
|
|
boolean projectResult = projectService.updateById(project);
|
|
|
if (!projectResult)
|
|
|
return RestResponse.fail(MessageUtils.get("msg.modify.fail"));
|
|
|
+ //停止服务发送消息
|
|
|
+ sendStopMessage(projectId, mtCompanyId);
|
|
|
if (CollUtil.isNotEmpty(resultList)) {
|
|
|
//批量停保项目下的电梯
|
|
|
resultList.forEach(entry -> entry.setLiftCompanyStatus(CommonEnum.LiftStatus.STOP_INSURANCE.getCode()));
|