Commit 11e0e1cd authored by zhangsen's avatar zhangsen

指令实施推送消息

parent e75182c7
......@@ -6,13 +6,17 @@ import java.util.Objects;
import com.yeejoin.amos.boot.module.common.biz.service.impl.SourceFileServiceImpl;
import com.yeejoin.amos.boot.module.jcs.api.entity.JcSituationDetail;
import com.yeejoin.amos.boot.module.jcs.api.mapper.JcSituationDetailMapper;
import com.yeejoin.amos.component.rule.config.RuleConfig;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
......@@ -51,6 +55,12 @@ public class PowerTransferCompanyController extends BaseController {
@Autowired
JcSituationDetailMapper jcSituationDetailMapper;
@Autowired
private EmqKeeper emqKeeper;
@Value("${mqtt.topic.command.power.deployment}")
private String topic;
/**
* 新增调派单位
*
......@@ -161,7 +171,7 @@ public class PowerTransferCompanyController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/jcSituationDetail/save", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "新增文字信息图片信息", notes = "新增文字信息图片信息")
public ResponseModel<Boolean> saveJcSituationDetail(@RequestBody JcSituationDetail jcSituationDetail) {
public ResponseModel<Boolean> saveJcSituationDetail(@RequestBody JcSituationDetail jcSituationDetail) throws MqttException {
if (Objects.isNull(jcSituationDetail.getAlertCalledId())) {
throw new BadRequest("警情ID不能为空");
}
......@@ -169,6 +179,10 @@ public class PowerTransferCompanyController extends BaseController {
// if (ObjectUtils.isNotEmpty(jcSituationDetail.getAttachments())) {
// sourceFileService.saveAttachments(jcSituationDetail.getSequenceNbr(), jcSituationDetail.getAttachments());
// }
// 自定义指令信息消息推送
// 定义指令信息消息推送 页面发送mqtt 默认发送 String 类型 0, 新警情 1 警情状态变化
emqKeeper.getMqttClient().publish(topic, "0".getBytes(), RuleConfig.DEFAULT_QOS, false);
return ResponseHelper.buildResponse(Boolean.TRUE);
}
......
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