|
@@ -1,24 +1,50 @@
|
|
|
package cn.com.ty.lift.business.maintenance.controller;
|
|
|
|
|
|
+import cn.com.ty.lift.business.emergency.dto.RepairResponse;
|
|
|
+import cn.com.ty.lift.business.emergency.entity.EmergencyRepair;
|
|
|
+import cn.com.ty.lift.business.emergency.service.EmergencyRepairService;
|
|
|
+import cn.com.ty.lift.business.library.dao.entity.PlatformCompanyLiftRelevance;
|
|
|
+import cn.com.ty.lift.business.library.service.PlatformCompanyLiftRelevanceService;
|
|
|
import cn.com.ty.lift.business.maintenance.dao.entity.model.request.PropertyMaintenanceVO;
|
|
|
import cn.com.ty.lift.business.maintenance.dao.entity.model.request.PropertyVo;
|
|
|
import cn.com.ty.lift.business.maintenance.dao.entity.model.response.DynamicMessageResponse;
|
|
|
import cn.com.ty.lift.business.maintenance.dao.entity.model.response.PropertyMtResponse;
|
|
|
import cn.com.ty.lift.business.maintenance.service.PropertyService;
|
|
|
+import cn.com.ty.lift.business.project.dao.entity.Region;
|
|
|
+import cn.com.ty.lift.business.push.service.PushUserService;
|
|
|
+import cn.com.ty.lift.common.constants.ApiConstants;
|
|
|
+import cn.com.ty.lift.common.constants.CommonEnum;
|
|
|
+import cn.com.ty.lift.common.constants.WebSocketConstants;
|
|
|
+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.ty.lift.common.utils.ValuePool;
|
|
|
+import cn.com.ty.lift.common.verify.Validate;
|
|
|
import cn.com.xwy.boot.web.dto.RestResponse;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import org.springframework.jms.core.JmsMessagingTemplate;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
@RestController
|
|
|
@AllArgsConstructor
|
|
|
@RequestMapping("property")
|
|
|
public class PropertyMaintenanceController {
|
|
|
private final PropertyService propertyService;
|
|
|
+ private final EmergencyRepairService emergencyRepairService;
|
|
|
+ private final PlatformCompanyLiftRelevanceService platformCompanyLiftRelevanceService;
|
|
|
+ private final JmsMessagingTemplate jmsMessagingTemplate;
|
|
|
+ private final PushUserService pushUserService;
|
|
|
|
|
|
@PostMapping("maintenance")
|
|
|
public RestResponse<?> maintenance(@RequestBody PropertyMaintenanceVO propertyMaintenanceVO) {
|
|
@@ -53,8 +79,58 @@ public class PropertyMaintenanceController {
|
|
|
return propertyService.queryJoinProjectList(propertyVo);
|
|
|
}
|
|
|
|
|
|
- @PostMapping("repair")
|
|
|
+ @PostMapping("repair/list")
|
|
|
public RestResponse<?> repair(@RequestBody PropertyVo propertyVo) {
|
|
|
return propertyService.queryRepairList(propertyVo);
|
|
|
}
|
|
|
-}
|
|
|
+
|
|
|
+ @PostMapping("repair/add")
|
|
|
+ public RestResponse<?> repairAdd(@RequestBody EmergencyRepair entity) {
|
|
|
+ Long mtCompanyId = entity.getMtCompanyId();
|
|
|
+ Long liftId = entity.getLiftId();
|
|
|
+ int repairing = emergencyRepairService.countRepairing(mtCompanyId, liftId);
|
|
|
+ Validate.notTrue(repairing > 0, ValuePool.EMERGENCY_HAVE_REPAIRING);
|
|
|
+ PlatformCompanyLiftRelevance relevance = platformCompanyLiftRelevanceService.findByMtCompanyAndLift(entity.getMtCompanyId(), entity.getLiftId());
|
|
|
+ if (Objects.nonNull(relevance)) {
|
|
|
+ Validate.notTrue(CommonEnum.LiftStatus.ANNUAL_INSPECTION.getCode().equals(relevance.getLiftCompanyStatus()), ValuePool.EMERGENCY_LIFT_IS_IN_INSPECTION);
|
|
|
+ }
|
|
|
+ //派单时间 急修单创建时间
|
|
|
+ entity.setHasEvaluate(0);
|
|
|
+ entity.setAssignTime(LocalDateTime.now());
|
|
|
+ entity.setStatus(ValuePool.EMERGENCY_STATE_TO_DO);
|
|
|
+ entity.setCreateDate(LocalDateTime.now());
|
|
|
+ boolean result = emergencyRepairService.save(entity);
|
|
|
+ if (result) {
|
|
|
+ //消息推送
|
|
|
+ Long id = entity.getId();
|
|
|
+ List<Long> userIds = new ArrayList<>();
|
|
|
+ Region region = pushUserService.findRegionByEmergencyRepair(id, mtCompanyId);
|
|
|
+ if (Objects.nonNull(region)) {
|
|
|
+ userIds.add(region.getUserId());
|
|
|
+ }
|
|
|
+ List<PushUserInfo> director = pushUserService.listHighDirector(mtCompanyId);
|
|
|
+ List<PushUserInfo> pushUserInfos = new ArrayList<>(director);
|
|
|
+ if (!userIds.isEmpty()) {
|
|
|
+ List<PushUserInfo> userInfos = pushUserService.listByUserIds(mtCompanyId, userIds);
|
|
|
+ pushUserInfos.addAll(userInfos);
|
|
|
+ }
|
|
|
+ if (!pushUserInfos.isEmpty()) {
|
|
|
+ RepairResponse info = emergencyRepairService.infoById(id);
|
|
|
+ PushMessage pushMessage = PushMessage.emergencyAssign(info.getAreaName(), info.getProjectName(), info.getDevicePosition(),
|
|
|
+ info.getRegistrationCode(), info.getCallerDate(), info.getIsTrapped(),
|
|
|
+ info.getCallerFaultDescription(), info.getWorkerName());
|
|
|
+ if (ApiConstants.ACCESS_TYPE_PUBLIC == entity.getMobileType()) {
|
|
|
+ pushMessage = PushMessage.emergencyAssignByProperty(info.getAreaName(), info.getProjectName(), info.getDevicePosition(),
|
|
|
+ info.getRegistrationCode(), info.getCallerDate(), info.getIsTrapped(),
|
|
|
+ info.getCallerFaultDescription(), info.getWorkerName());
|
|
|
+ //物业端发起的急修要将消息推送到pc端
|
|
|
+ List<Long> pushUserIds = pushUserInfos.stream().map(PushUserInfo::getUserId).collect(Collectors.toList());
|
|
|
+ SendMessageUtil.sendMessageToPC(jmsMessagingTemplate, pushUserIds, pushMessage.getContent(),
|
|
|
+ WebSocketConstants.MessageType.EMERGENCY_MSG);
|
|
|
+ }
|
|
|
+ pushMessage.sendTokenOnPlatform(jmsMessagingTemplate, pushUserInfos);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return RestResponse.success(result);
|
|
|
+ }
|
|
|
+}
|