Browse Source

扫码报警图片

develop
lau572 3 months ago
parent
commit
235fe4c236
  1. 64
      zc-business/src/main/java/com/zc/business/controller/CodeScanningAlarmController.java

64
zc-business/src/main/java/com/zc/business/controller/CodeScanningAlarmController.java

@ -1,10 +1,14 @@
package com.zc.business.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.StringUtils;
import com.zc.business.domain.DcEventProcess;
import com.zc.business.domain.DcWarning;
import com.zc.business.enums.UniversalEnum;
import com.zc.business.mapper.DcEventProcessMapper;
import com.zc.business.service.IDcWarningService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.PostMapping;
@ -32,6 +36,8 @@ public class CodeScanningAlarmController extends BaseController {
@Resource
private IDcWarningService dcWarningService;
@Resource
private DcEventProcessMapper dcEventProcessMapper;
/**
* 扫码报警事件回调函数
@ -98,4 +104,62 @@ public class CodeScanningAlarmController extends BaseController {
}
}
@PostMapping(value = "/updateAlarm")
public AjaxResult updateAlarm(@RequestBody Map<String, Object> params) {
if (!params.containsKey("id") || !params.containsKey("type") || !params.containsKey("url")){
return AjaxResult.error("参数错误");
}
String id = String.valueOf(params.get("id"));
String type = String.valueOf(params.get("type"));
String url = String.valueOf(params.get("url"));
if (StringUtils.isEmpty(id) || StringUtils.isEmpty(type) || StringUtils.isEmpty(url)){
return AjaxResult.error("参数错误");
}
HashMap<String, Object> oldData = dcWarningService.selectAlarmById(id);
if (oldData == null){
return AjaxResult.error("无此事件");
}
JSONObject otherConfig = JSONObject.parseObject(oldData.get("otherConfig").toString());
if (type.equals("video")){
JSONArray videoUrl = new JSONArray();
if (otherConfig.containsKey("videoUrl")){
videoUrl = otherConfig.getJSONArray("videoUrl");
}
videoUrl.add(url);
otherConfig.put("videoUrl",videoUrl);
} else {
JSONArray imgUrl = new JSONArray();
if (otherConfig.containsKey("imgUrl")){
imgUrl = otherConfig.getJSONArray("imgUrl");
}
imgUrl.add(url);
otherConfig.put("imgUrl",imgUrl);
}
DcWarning dcWarning = new DcWarning();
dcWarning.setId(oldData.get("id").toString());
dcWarning.setOtherConfig(String.valueOf(JSONObject.parseObject(JSONObject.toJSONString(otherConfig))));
dcWarningService.updateDcWarning(dcWarning);
String warningState = oldData.get("warningState").toString();
if (warningState.equals("2")){
DcEventProcess dcEventProcess = new DcEventProcess();
dcEventProcess.setEventId(oldData.get("id").toString());
dcEventProcess.setSource(2);
if (type.equals("video")){
dcEventProcess.setType("mp4");
} else {
dcEventProcess.setType("png");
}
dcEventProcess.setContext(url);
dcEventProcess.setOperatorName("上报人");
dcEventProcess.setOperationTime(new Date());
dcEventProcessMapper.insertDcEventProcess(dcEventProcess);
}
return AjaxResult.success("添加成功");
}
}

Loading…
Cancel
Save