Commit 8e387215 authored by helinlin's avatar helinlin

优化联动控制逻辑

parent 1b48627c
...@@ -17,5 +17,5 @@ import java.util.List; ...@@ -17,5 +17,5 @@ import java.util.List;
*/ */
public interface ControllerMapper extends BaseMapper<Controller> { public interface ControllerMapper extends BaseMapper<Controller> {
public List<ControllerDto> getCurrentStationController(@Param("sequenceNbr") Long sequenceNbr); List<ControllerDto> getCurrentStationController(@Param("sequenceNbr") Long sequenceNbr);
} }
...@@ -3,19 +3,14 @@ package com.yeejoin.amos.boot.module.jcs.biz.controller; ...@@ -3,19 +3,14 @@ package com.yeejoin.amos.boot.module.jcs.biz.controller;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.jcs.api.dto.ControllerDto; import com.yeejoin.amos.boot.module.jcs.api.dto.ControllerDto;
import com.yeejoin.amos.boot.module.jcs.api.entity.Controller; import com.yeejoin.amos.boot.module.jcs.api.entity.Controller;
import com.yeejoin.amos.boot.module.jcs.api.entity.ControllerLog;
import com.yeejoin.amos.boot.module.jcs.api.enums.ControllerGroupEnum; import com.yeejoin.amos.boot.module.jcs.api.enums.ControllerGroupEnum;
import com.yeejoin.amos.boot.module.jcs.api.enums.ControllerTypeEnum; import com.yeejoin.amos.boot.module.jcs.api.enums.ControllerTypeEnum;
import com.yeejoin.amos.boot.module.jcs.biz.service.impl.ControllerEquipServiceImpl;
import com.yeejoin.amos.boot.module.jcs.biz.service.impl.ControllerLogServiceImpl;
import com.yeejoin.amos.boot.module.jcs.biz.service.impl.ControllerServiceImpl; import com.yeejoin.amos.boot.module.jcs.biz.service.impl.ControllerServiceImpl;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
...@@ -41,7 +36,7 @@ public class ControllerController extends BaseController { ...@@ -41,7 +36,7 @@ public class ControllerController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST", value = "更新联动控制器状态", notes = "更新联动控制器状态") @ApiOperation(httpMethod = "POST", value = "更新联动控制器状态", notes = "更新联动控制器状态")
@PostMapping(value = "/updateControllerState") @PostMapping(value = "/updateControllerState")
public ResponseModel<Object> updateControllerState(@RequestBody Controller[] controllers) { public ResponseModel<Object> updateControllerState(@RequestBody ControllerDto[] controllers) {
return ResponseHelper.buildResponse(controllerServiceImpl.changeControllerState(controllers)); return ResponseHelper.buildResponse(controllerServiceImpl.changeControllerState(controllers));
} }
...@@ -66,6 +61,7 @@ public class ControllerController extends BaseController { ...@@ -66,6 +61,7 @@ public class ControllerController extends BaseController {
BeanUtils.copyProperties(controller, controllerDto); BeanUtils.copyProperties(controller, controllerDto);
controllerDto.setTypeEnum(anEnum); controllerDto.setTypeEnum(anEnum);
controllerDto.setTypeDescription(anEnum.getName()); controllerDto.setTypeDescription(anEnum.getName());
controllerDto.setState("0");
controllerDtos.add(controllerDto); controllerDtos.add(controllerDto);
} }
}); });
......
package com.yeejoin.amos.boot.module.jcs.biz.controller; package com.yeejoin.amos.boot.module.jcs.biz.controller;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.jcs.api.dto.ControllerEquipDto;
import com.yeejoin.amos.boot.module.jcs.api.entity.ControllerEquip; import com.yeejoin.amos.boot.module.jcs.api.entity.ControllerEquip;
import com.yeejoin.amos.boot.module.jcs.biz.service.impl.ControllerEquipServiceImpl; import com.yeejoin.amos.boot.module.jcs.biz.service.impl.ControllerEquipServiceImpl;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
......
package com.yeejoin.amos.boot.module.jcs.biz.service.impl; package com.yeejoin.amos.boot.module.jcs.biz.service.impl;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yeejoin.amos.boot.module.common.api.feign.JcsControlServerClient; import com.yeejoin.amos.boot.module.common.api.feign.JcsControlServerClient;
import com.yeejoin.amos.boot.module.jcs.api.dto.ControllerDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.ControllerEquipDto;
import com.yeejoin.amos.boot.module.jcs.api.entity.Controller; import com.yeejoin.amos.boot.module.jcs.api.entity.Controller;
import com.yeejoin.amos.boot.module.jcs.api.entity.ControllerEquip;
import com.yeejoin.amos.boot.module.jcs.api.entity.ControllerLog;
import com.yeejoin.amos.boot.module.jcs.api.mapper.ControllerEquipMapper;
import com.yeejoin.amos.boot.module.jcs.api.service.IControllerEquipService; import com.yeejoin.amos.boot.module.jcs.api.service.IControllerEquipService;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import com.yeejoin.amos.boot.module.jcs.api.dto.ControllerEquipDto; import java.util.Date;
import com.yeejoin.amos.boot.module.jcs.api.entity.ControllerEquip; import java.util.List;
import com.yeejoin.amos.boot.module.jcs.api.mapper.ControllerEquipMapper;
/** /**
* <pre> * <pre>
...@@ -26,10 +32,17 @@ import com.yeejoin.amos.boot.module.jcs.api.mapper.ControllerEquipMapper; ...@@ -26,10 +32,17 @@ import com.yeejoin.amos.boot.module.jcs.api.mapper.ControllerEquipMapper;
*/ */
@Service @Service
public class ControllerEquipServiceImpl extends BaseService<ControllerEquipDto, ControllerEquip, ControllerEquipMapper> implements IControllerEquipService { public class ControllerEquipServiceImpl extends BaseService<ControllerEquipDto, ControllerEquip, ControllerEquipMapper> implements IControllerEquipService {
public static final String CONTROLLER_STATE_CHANGED_TOPIC = "controllerStateChanged";
@Autowired @Autowired
JcsControlServerClient jcsControlServerClient; JcsControlServerClient jcsControlServerClient;
@Autowired
ControllerLogServiceImpl controllerLogServiceImpl;
@Autowired
private EmqKeeper emqKeeper;
public List<ControllerEquipDto> queryAllForList() { public List<ControllerEquipDto> queryAllForList() {
return this.queryForList("", false); return this.queryForList("", false);
} }
...@@ -38,8 +51,10 @@ public class ControllerEquipServiceImpl extends BaseService<ControllerEquipDto, ...@@ -38,8 +51,10 @@ public class ControllerEquipServiceImpl extends BaseService<ControllerEquipDto,
* 改变警铃状态 0关闭,1开启 * 改变警铃状态 0关闭,1开启
*/ */
@Async @Async
public void changeBell(Controller controller, String type) { public void changeBell(ControllerDto controller, String type) {
if (controller == null) return; if (controller == null) return;
controller.setState(type);
saveLog(controller);
List<ControllerEquip> list = getControllerEquips(controller); List<ControllerEquip> list = getControllerEquips(controller);
list.forEach(controllerEquip -> jcsControlServerClient.sendBellAction(controllerEquip.getNum(), type)); list.forEach(controllerEquip -> jcsControlServerClient.sendBellAction(controllerEquip.getNum(), type));
} }
...@@ -48,8 +63,10 @@ public class ControllerEquipServiceImpl extends BaseService<ControllerEquipDto, ...@@ -48,8 +63,10 @@ public class ControllerEquipServiceImpl extends BaseService<ControllerEquipDto,
* 改变广播状态 0关闭,1开启 * 改变广播状态 0关闭,1开启
*/ */
@Async @Async
public void changeBroadcast(Controller controller, String type) { public void changeBroadcast(ControllerDto controller, String type) {
if (controller == null) return; if (controller == null) return;
controller.setState(type);
saveLog(controller);
List<ControllerEquip> list = getControllerEquips(controller); List<ControllerEquip> list = getControllerEquips(controller);
list.forEach(controllerEquip -> jcsControlServerClient.sendFileAction(controllerEquip.getNum(), "")); list.forEach(controllerEquip -> jcsControlServerClient.sendFileAction(controllerEquip.getNum(), ""));
} }
...@@ -58,14 +75,35 @@ public class ControllerEquipServiceImpl extends BaseService<ControllerEquipDto, ...@@ -58,14 +75,35 @@ public class ControllerEquipServiceImpl extends BaseService<ControllerEquipDto,
* 改变车库门状态 0关闭,1开启 * 改变车库门状态 0关闭,1开启
*/ */
@Async @Async
public void changeDoor(Controller controller, String type) { public void changeDoor(ControllerDto controller, String type) {
if (controller == null) return; if (controller == null) return;
controller.setState(type);
saveLog(controller);
List<ControllerEquip> list = getControllerEquips(controller); List<ControllerEquip> list = getControllerEquips(controller);
list.forEach(controllerEquip -> jcsControlServerClient.writeStateAction(controller.getIp(), controller.getPort(), Integer.parseInt(controllerEquip.getNum()), type)); list.forEach(controllerEquip -> jcsControlServerClient.writeStateAction(controller.getIp(), controller.getPort(), Integer.parseInt(controllerEquip.getNum()), type));
} }
private List<ControllerEquip> getControllerEquips(Controller controller) { private List<ControllerEquip> getControllerEquips(ControllerDto controller) {
LambdaQueryWrapper<ControllerEquip> wrapper = new LambdaQueryWrapper<ControllerEquip>().eq(ControllerEquip::getControllerSeq, controller.getSequenceNbr()); LambdaQueryWrapper<ControllerEquip> wrapper = new LambdaQueryWrapper<ControllerEquip>().eq(ControllerEquip::getControllerSeq, controller.getSequenceNbr());
return list(wrapper); return list(wrapper);
} }
/**
* 保存操作日志
*/
private void saveLog(ControllerDto controller) {
if (controller == null) return;
ControllerLog controllerLog = new ControllerLog();
controllerLog.setControllerSeq(controller.getSequenceNbr());
controllerLog.setState(controller.getState());
controllerLog.setExecuteDate(new Date());
controllerLogServiceImpl.save(controllerLog);
// 分发状态变更通知
try {
String value = new ObjectMapper().writeValueAsString(controller);
emqKeeper.getMqttClient().publish(CONTROLLER_STATE_CHANGED_TOPIC, value.getBytes(), 2, true);
} catch (MqttException | JsonProcessingException e) {
e.printStackTrace();
}
}
} }
package com.yeejoin.amos.boot.module.jcs.biz.service.impl; package com.yeejoin.amos.boot.module.jcs.biz.service.impl;
import java.util.*; import java.util.*;
import java.util.function.Function;
import java.util.function.IntFunction;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.module.common.api.service.IDutyCarService; import com.yeejoin.amos.boot.module.common.api.service.IDutyCarService;
import com.yeejoin.amos.boot.module.jcs.api.dto.AircraftDto; import com.yeejoin.amos.boot.module.jcs.api.dto.*;
import com.yeejoin.amos.boot.module.jcs.api.entity.*; import com.yeejoin.amos.boot.module.jcs.api.entity.*;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -35,17 +38,6 @@ import com.yeejoin.amos.boot.module.common.api.entity.FireTeam; ...@@ -35,17 +38,6 @@ import com.yeejoin.amos.boot.module.common.api.entity.FireTeam;
import com.yeejoin.amos.boot.module.common.api.feign.EquipFeignClient; import com.yeejoin.amos.boot.module.common.api.feign.EquipFeignClient;
import com.yeejoin.amos.boot.module.common.api.mapper.DynamicFormInstanceMapper; import com.yeejoin.amos.boot.module.common.api.mapper.DynamicFormInstanceMapper;
import com.yeejoin.amos.boot.module.common.biz.service.impl.DutyCarServiceImpl; import com.yeejoin.amos.boot.module.common.biz.service.impl.DutyCarServiceImpl;
import com.yeejoin.amos.boot.module.jcs.api.dto.AlertCalledObjsDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.AlertCalledRo;
import com.yeejoin.amos.boot.module.jcs.api.dto.CarStatusInfoDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.PowerCarCountDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.PowerCompanyCountDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferCompanyDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferCompanyResourcesDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferResourceDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferSimpleDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.ResourceStatisticsDto;
import com.yeejoin.amos.boot.module.jcs.api.enums.AlertFeedbackStatusEnum; import com.yeejoin.amos.boot.module.jcs.api.enums.AlertFeedbackStatusEnum;
import com.yeejoin.amos.boot.module.jcs.api.enums.DutyInfoEnum; import com.yeejoin.amos.boot.module.jcs.api.enums.DutyInfoEnum;
import com.yeejoin.amos.boot.module.jcs.api.enums.FireBrigadeTypeEnum; import com.yeejoin.amos.boot.module.jcs.api.enums.FireBrigadeTypeEnum;
...@@ -424,8 +416,9 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe ...@@ -424,8 +416,9 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe
List<AlertFormValue> alertFormValue = alertCalledObjsDto.getAlertFormValue(); List<AlertFormValue> alertFormValue = alertCalledObjsDto.getAlertFormValue();
String responseLevel = ""; String responseLevel = "";
List<AlertFormValue> list1 = alertFormValue.stream().filter(formValue -> formValue.getFieldCode().equals("responseLevel") ).collect(Collectors.toList());; List<AlertFormValue> list1 = alertFormValue.stream().filter(formValue -> formValue.getFieldCode().equals("responseLevel")).collect(Collectors.toList());
if(list1.size() > 0) { ;
if (list1.size() > 0) {
responseLevel = list1.get(0).getFieldValue(); responseLevel = list1.get(0).getFieldValue();
} }
...@@ -483,12 +476,17 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe ...@@ -483,12 +476,17 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe
powerTransferCompanyDto.setPowerTransferCompanyResourcesDtoList(resourcesDtoList); powerTransferCompanyDto.setPowerTransferCompanyResourcesDtoList(resourcesDtoList);
// 更新车辆状态 // 更新车辆状态
equipFeignService.updateCarStatus(carStatusInfoDtoList); equipFeignService.updateCarStatus(carStatusInfoDtoList);
// 警情力量调派时,点击【任务派发】后,如果被调派的 力量包含消防车,那么该消防车所在的 大队的警铃、广播自动 启动,消防车所在的车库门自动开启 // 警情力量调派时,点击【任务派发】后,如果被调派的 力量包含消防车,那么该消防车所在的 大队的警铃、广播自动 启动,消防车所在的车库门自动开启
try { try {
List<Controller> controllers = controllerServiceImpl.list(new LambdaQueryWrapper<Controller>().eq(Controller::getFireTeamSeq, powerTransferCompanyDto.getCompanyId())); List<Controller> controllers = controllerServiceImpl.list(new LambdaQueryWrapper<Controller>().eq(Controller::getFireTeamSeq, powerTransferCompanyDto.getCompanyId()));
if (controllers.size() > 0) { if (controllers.size() > 0) {
controllerServiceImpl.changeControllerState(controllers.toArray(new Controller[0])); ControllerDto[] controllerDtos = new ControllerDto[controllers.size()];
for (int i = 0; i < controllers.size(); i++) {
ControllerDto controllerDto = new ControllerDto();
BeanUtils.copyProperties(controllers.get(i), controllerDto);
controllerDtos[i] = controllerDto;
}
controllerServiceImpl.changeControllerState(controllerDtos);
} }
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage()); log.error(e.getMessage());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment