Commit ce84d7a6 authored by tangwei's avatar tangwei

Merge branch 'developer' of http://172.16.10.76/moa/amos-boot-biz into developer

parents 62cfc63d 97d116aa
......@@ -125,15 +125,18 @@ public class MetaHandler implements MetaObjectHandler {
*/
@Override
public void updateFill(MetaObject metaObject) {
String userId = RequestContext.getExeUserId();
ReginParams reginParams =
JSONObject.parseObject(null != redisUtils.get(RedisKey.buildReginKey(userId, getToken())) ?
redisUtils.get(RedisKey.buildReginKey(userId, getToken())).toString() : null, ReginParams.class);
if (ObjectUtils.isEmpty(reginParams)) {
return;
Class clazz = metaObject.getOriginalObject().getClass();
FillCommonUserField annotation = (FillCommonUserField) clazz.getAnnotation(FillCommonUserField.class);
if (annotation == null || annotation.isAutoFill()) {
String userId = RequestContext.getExeUserId();
ReginParams reginParams =
JSONObject.parseObject(null != redisUtils.get(RedisKey.buildReginKey(userId, getToken())) ?
redisUtils.get(RedisKey.buildReginKey(userId, getToken())).toString() : null, ReginParams.class);
if (ObjectUtils.isEmpty(reginParams)) {
return;
}
AgencyUserModel agencyUserModel = reginParams.getUserModel();
recInfoUpdate(metaObject, agencyUserModel);
}
AgencyUserModel agencyUserModel = reginParams.getUserModel();
recInfoUpdate(metaObject, agencyUserModel);
}
}
\ No newline at end of file
......@@ -17,5 +17,5 @@ import java.util.List;
*/
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;
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.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.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 io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
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.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
......@@ -41,7 +36,7 @@ public class ControllerController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST", value = "更新联动控制器状态", notes = "更新联动控制器状态")
@PostMapping(value = "/updateControllerState")
public ResponseModel<Object> updateControllerState(@RequestBody Controller[] controllers) {
public ResponseModel<Object> updateControllerState(@RequestBody ControllerDto[] controllers) {
return ResponseHelper.buildResponse(controllerServiceImpl.changeControllerState(controllers));
}
......@@ -66,6 +61,7 @@ public class ControllerController extends BaseController {
BeanUtils.copyProperties(controller, controllerDto);
controllerDto.setTypeEnum(anEnum);
controllerDto.setTypeDescription(anEnum.getName());
controllerDto.setState("0");
controllerDtos.add(controllerDto);
}
});
......
package com.yeejoin.amos.boot.module.jcs.biz.controller;
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.biz.service.impl.ControllerEquipServiceImpl;
import io.swagger.annotations.Api;
......
package com.yeejoin.amos.boot.module.jcs.biz.service.impl;
import java.util.List;
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.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.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 org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.rdbms.service.BaseService;
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.mapper.ControllerEquipMapper;
import java.util.Date;
import java.util.List;
/**
* <pre>
......@@ -26,10 +32,17 @@ import com.yeejoin.amos.boot.module.jcs.api.mapper.ControllerEquipMapper;
*/
@Service
public class ControllerEquipServiceImpl extends BaseService<ControllerEquipDto, ControllerEquip, ControllerEquipMapper> implements IControllerEquipService {
public static final String CONTROLLER_STATE_CHANGED_TOPIC = "controllerStateChanged";
@Autowired
JcsControlServerClient jcsControlServerClient;
@Autowired
ControllerLogServiceImpl controllerLogServiceImpl;
@Autowired
private EmqKeeper emqKeeper;
public List<ControllerEquipDto> queryAllForList() {
return this.queryForList("", false);
}
......@@ -38,8 +51,10 @@ public class ControllerEquipServiceImpl extends BaseService<ControllerEquipDto,
* 改变警铃状态 0关闭,1开启
*/
@Async
public void changeBell(Controller controller, String type) {
public void changeBell(ControllerDto controller, String type) {
if (controller == null) return;
controller.setState(type);
saveLog(controller);
List<ControllerEquip> list = getControllerEquips(controller);
list.forEach(controllerEquip -> jcsControlServerClient.sendBellAction(controllerEquip.getNum(), type));
}
......@@ -48,8 +63,10 @@ public class ControllerEquipServiceImpl extends BaseService<ControllerEquipDto,
* 改变广播状态 0关闭,1开启
*/
@Async
public void changeBroadcast(Controller controller, String type) {
public void changeBroadcast(ControllerDto controller, String type) {
if (controller == null) return;
controller.setState(type);
saveLog(controller);
List<ControllerEquip> list = getControllerEquips(controller);
list.forEach(controllerEquip -> jcsControlServerClient.sendFileAction(controllerEquip.getNum(), ""));
}
......@@ -58,14 +75,35 @@ public class ControllerEquipServiceImpl extends BaseService<ControllerEquipDto,
* 改变车库门状态 0关闭,1开启
*/
@Async
public void changeDoor(Controller controller, String type) {
public void changeDoor(ControllerDto controller, String type) {
if (controller == null) return;
controller.setState(type);
saveLog(controller);
List<ControllerEquip> list = getControllerEquips(controller);
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());
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;
import java.util.*;
import java.util.function.Function;
import java.util.function.IntFunction;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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 org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -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.mapper.DynamicFormInstanceMapper;
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.DutyInfoEnum;
import com.yeejoin.amos.boot.module.jcs.api.enums.FireBrigadeTypeEnum;
......@@ -424,8 +416,9 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe
List<AlertFormValue> alertFormValue = alertCalledObjsDto.getAlertFormValue();
String responseLevel = "";
List<AlertFormValue> list1 = alertFormValue.stream().filter(formValue -> formValue.getFieldCode().equals("responseLevel") ).collect(Collectors.toList());;
if(list1.size() > 0) {
List<AlertFormValue> list1 = alertFormValue.stream().filter(formValue -> formValue.getFieldCode().equals("responseLevel")).collect(Collectors.toList());
;
if (list1.size() > 0) {
responseLevel = list1.get(0).getFieldValue();
}
......@@ -483,12 +476,17 @@ public class PowerTransferServiceImpl extends BaseService<PowerTransferDto, Powe
powerTransferCompanyDto.setPowerTransferCompanyResourcesDtoList(resourcesDtoList);
// 更新车辆状态
equipFeignService.updateCarStatus(carStatusInfoDtoList);
// 警情力量调派时,点击【任务派发】后,如果被调派的 力量包含消防车,那么该消防车所在的 大队的警铃、广播自动 启动,消防车所在的车库门自动开启
try {
List<Controller> controllers = controllerServiceImpl.list(new LambdaQueryWrapper<Controller>().eq(Controller::getFireTeamSeq, powerTransferCompanyDto.getCompanyId()));
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) {
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