Commit 0d7d9a5a authored by chenhao's avatar chenhao

解决方法内添加异步注解导致循环引用的问题

parent f7050a53
...@@ -8,8 +8,11 @@ import java.util.stream.Collectors; ...@@ -8,8 +8,11 @@ import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
...@@ -21,6 +24,7 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -21,6 +24,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.component.event.RestEventTrigger; import org.typroject.tyboot.component.event.RestEventTrigger;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
...@@ -54,6 +58,7 @@ import com.yeejoin.amos.boot.module.jcs.api.enums.AlertStatusEnum; ...@@ -54,6 +58,7 @@ import com.yeejoin.amos.boot.module.jcs.api.enums.AlertStatusEnum;
import com.yeejoin.amos.boot.module.jcs.biz.service.impl.AlertCalledServiceImpl; import com.yeejoin.amos.boot.module.jcs.biz.service.impl.AlertCalledServiceImpl;
import com.yeejoin.amos.boot.module.jcs.biz.service.impl.AlertFormValueServiceImpl; import com.yeejoin.amos.boot.module.jcs.biz.service.impl.AlertFormValueServiceImpl;
import com.yeejoin.amos.boot.module.jcs.biz.service.impl.ESAlertCalledService; import com.yeejoin.amos.boot.module.jcs.biz.service.impl.ESAlertCalledService;
import com.yeejoin.amos.component.rule.config.RuleConfig;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -69,7 +74,7 @@ import io.swagger.annotations.ApiOperation; ...@@ -69,7 +74,7 @@ import io.swagger.annotations.ApiOperation;
@Api(tags = "警情接警记录Api") @Api(tags = "警情接警记录Api")
@RequestMapping(value = "/alert-called") @RequestMapping(value = "/alert-called")
public class AlertCalledController extends BaseController { public class AlertCalledController extends BaseController {
private final Logger logger = LogManager.getLogger(AlertCalledController.class);
@Autowired @Autowired
LatentDangerFeignClient latentDangerFeignClient; LatentDangerFeignClient latentDangerFeignClient;
@Autowired @Autowired
...@@ -92,6 +97,12 @@ public class AlertCalledController extends BaseController { ...@@ -92,6 +97,12 @@ public class AlertCalledController extends BaseController {
private static String ALETR_TYPE_AID = "1214"; private static String ALETR_TYPE_AID = "1214";
private static String ALETR_TYPE_AID_STATUS = "patientStatus"; private static String ALETR_TYPE_AID_STATUS = "patientStatus";
@Autowired
private EmqKeeper emqKeeper;
@Value("${mqtt.topic.command.knowledgebase.alert.match}")
private String topicMatch;
/** /**
* 新增警情接警记录 * 新增警情接警记录
* *
...@@ -135,9 +146,22 @@ public class AlertCalledController extends BaseController { ...@@ -135,9 +146,22 @@ public class AlertCalledController extends BaseController {
} }
alertCalledObjsDto.setAlertCalled(alertCalled); alertCalledObjsDto.setAlertCalled(alertCalled);
alertCalledObjsDto = iAlertCalledService.createAlertCalled(alertCalledObjsDto); alertCalledObjsDto = iAlertCalledService.createAlertCalled(alertCalledObjsDto);
toSendCompletePoliceSituationMatch(alertCalledObjsDto.getAlertCalled().getSequenceNbr());
return ResponseHelper.buildResponse(alertCalledObjsDto.getAlertCalled()); return ResponseHelper.buildResponse(alertCalledObjsDto.getAlertCalled());
} }
@Async
public void toSendCompletePoliceSituationMatch(Long id){
try {
Object result = iAlertCalledService.toCompletePoliceSituationMatch(id);
List<Object> list= (List<Object>) result;
if(list.size()>0) {
emqKeeper.getMqttClient().publish(topicMatch, result.toString().getBytes(), RuleConfig.DEFAULT_QOS, false);
}
} catch (Exception e) {
logger.info(topicMatch+":警情id"+id+"获取匹配的预案失败------------"+e.getMessage());
}
}
/** /**
* 根据id删除 * 根据id删除
* *
......
...@@ -16,7 +16,6 @@ import org.apache.logging.log4j.Logger; ...@@ -16,7 +16,6 @@ import org.apache.logging.log4j.Logger;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.component.emq.EmqKeeper; import org.typroject.tyboot.component.emq.EmqKeeper;
...@@ -399,25 +398,14 @@ public class AlertCalledServiceImpl extends BaseService<AlertCalledDto, AlertCal ...@@ -399,25 +398,14 @@ public class AlertCalledServiceImpl extends BaseService<AlertCalledDto, AlertCal
*/ */
eSAlertCalledService.saveAlertCalledToES(alertCalled); eSAlertCalledService.saveAlertCalledToES(alertCalled);
} }
toSendCompletePoliceSituationMatch(alertCalled.getSequenceNbr()); // toSendCompletePoliceSituationMatch(alertCalled.getSequenceNbr());
return alertCalledObjsDto; return alertCalledObjsDto;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
throw new RuntimeException("报送失败,系统异常!"); throw new RuntimeException("报送失败,系统异常!");
} }
} }
//@Async
public void toSendCompletePoliceSituationMatch(Long id){
try {
Object result = toCompletePoliceSituationMatch(id);
List<Object> list= (List<Object>) result;
if(list.size()>0) {
emqKeeper.getMqttClient().publish(topicMatch, result.toString().getBytes(), RuleConfig.DEFAULT_QOS, false);
}
} catch (Exception e) {
logger.info(topicMatch+":警情id"+id+"获取匹配的预案失败------------"+e.getMessage());
}
}
/** /**
* 根据id 修改警情 type:警情相关 操作类型 0警情续报 1非警情确认 2 警情结案 * 根据id 修改警情 type:警情相关 操作类型 0警情续报 1非警情确认 2 警情结案
*/ */
......
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