Browse Source

优化扫码报警上传数据格式

develop
zhaoxianglong 8 months ago
parent
commit
ee7eb850b8
  1. 14
      zc-business/src/main/java/com/zc/business/controller/CodeScanningAlarmController.java
  2. 2
      zc-business/src/main/java/com/zc/business/mapper/DcWarningMapper.java
  3. 2
      zc-business/src/main/java/com/zc/business/service/IDcWarningService.java
  4. 5
      zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java
  5. 2
      zc-business/src/main/resources/mapper/business/DcWarningMapper.xml

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

@ -1,8 +1,8 @@
package com.zc.business.controller; package com.zc.business.controller;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.zc.business.domain.DcWarning; import com.zc.business.domain.DcWarning;
import com.zc.business.service.IDcWarningService; import com.zc.business.service.IDcWarningService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@ -36,10 +36,11 @@ public class CodeScanningAlarmController extends BaseController {
*/ */
@PostMapping(value = "/event") @PostMapping(value = "/event")
public AjaxResult codeScanningAlarmControllerEvent(@RequestBody Map<String, Object> returnParameters) { public AjaxResult codeScanningAlarmControllerEvent(@RequestBody Map<String, Object> returnParameters) {
String id = String.valueOf(returnParameters.get("id"));
DcWarning dcWarning = new DcWarning(); DcWarning dcWarning = new DcWarning();
//设置事件Id UUID无下划线格式32 dcWarning.setId(id);
String uuid = IdUtils.fastSimpleUUID(); dcWarning.setOtherConfig(String.valueOf(JSONObject.parseObject(JSONObject.toJSONString(returnParameters))));
dcWarning.setId(uuid); if (dcWarningService.selectDcWarningById(id) == null) {
dcWarning.setStakeMark(String.valueOf(returnParameters.get("stakeNum"))); dcWarning.setStakeMark(String.valueOf(returnParameters.get("stakeNum")));
String roadCode = String.valueOf(returnParameters.get("roadCode")); String roadCode = String.valueOf(returnParameters.get("roadCode"));
dcWarning.setDirection(Objects.equals(roadCode, "1") ? "3" : "1"); dcWarning.setDirection(Objects.equals(roadCode, "1") ? "3" : "1");
@ -76,9 +77,12 @@ public class CodeScanningAlarmController extends BaseController {
} }
String warningTitle = "济荷高速:" + (Objects.equals(roadCode, "1") ? "济南方向" : "菏泽方向") + "发生" + (Integer.parseInt(accidentType) >= 4 ? "交通事故事件" : "车辆故障事件"); String warningTitle = "济荷高速:" + (Objects.equals(roadCode, "1") ? "济南方向" : "菏泽方向") + "发生" + (Integer.parseInt(accidentType) >= 4 ? "交通事故事件" : "车辆故障事件");
dcWarning.setWarningTitle(warningTitle); dcWarning.setWarningTitle(warningTitle);
dcWarning.setOtherConfig(returnParameters.toString());
dcWarning.setWarningSource(5); dcWarning.setWarningSource(5);
dcWarning.setWarningState(1); dcWarning.setWarningState(1);
return AjaxResult.success(dcWarningService.insertDcWarning(dcWarning)); return AjaxResult.success(dcWarningService.insertDcWarning(dcWarning));
} else {
return AjaxResult.success(dcWarningService.updateDcWarning(dcWarning));
} }
} }
}

2
zc-business/src/main/java/com/zc/business/mapper/DcWarningMapper.java

@ -19,7 +19,7 @@ public interface DcWarningMapper
* @param id 预警信息主键 * @param id 预警信息主键
* @return 预警信息 * @return 预警信息
*/ */
public HashMap<String,Object> selectDcWarningById(Integer id); public DcWarning selectDcWarningById(String id);
/** /**
* 查询预警信息列表 * 查询预警信息列表

2
zc-business/src/main/java/com/zc/business/service/IDcWarningService.java

@ -22,7 +22,7 @@ public interface IDcWarningService
* @param id 预警信息主键 * @param id 预警信息主键
* @return 预警信息 * @return 预警信息
*/ */
public HashMap<String,Object> selectDcWarningById(Integer id); public DcWarning selectDcWarningById(String id);
/** /**
* 查询预警信息列表 * 查询预警信息列表

5
zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java

@ -4,6 +4,7 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils; import com.ruoyi.common.utils.uuid.IdUtils;
import com.zc.business.domain.DcDevice;
import com.zc.business.domain.DcEvent; import com.zc.business.domain.DcEvent;
import com.zc.business.domain.DcWarning; import com.zc.business.domain.DcWarning;
import com.zc.business.domain.DcWarningBatchConvert; import com.zc.business.domain.DcWarningBatchConvert;
@ -44,7 +45,7 @@ public class DcWarningServiceImpl implements IDcWarningService
* @return 预警信息 * @return 预警信息
*/ */
@Override @Override
public HashMap<String, Object> selectDcWarningById(Integer id) public DcWarning selectDcWarningById(String id)
{ {
return dcWarningMapper.selectDcWarningById(id); return dcWarningMapper.selectDcWarningById(id);
} }
@ -76,9 +77,11 @@ public class DcWarningServiceImpl implements IDcWarningService
public int insertDcWarning(DcWarning dcWarning) public int insertDcWarning(DcWarning dcWarning)
{ {
dcWarning.setCreateTime(DateUtils.getNowDate()); dcWarning.setCreateTime(DateUtils.getNowDate());
if (dcWarning.getId()==null) {
//设置事件Id UUID无下划线格式32 //设置事件Id UUID无下划线格式32
String uuid = IdUtils.fastSimpleUUID(); String uuid = IdUtils.fastSimpleUUID();
dcWarning.setId(uuid); dcWarning.setId(uuid);
}
return dcWarningMapper.insertDcWarning(dcWarning); return dcWarningMapper.insertDcWarning(dcWarning);
} }

2
zc-business/src/main/resources/mapper/business/DcWarningMapper.xml

@ -64,7 +64,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where> </where>
</select> </select>
<select id="selectDcWarningById" parameterType="Integer" resultType="hashmap"> <select id="selectDcWarningById" parameterType="string" resultType="com.zc.business.domain.DcWarning">
<include refid="selectDcWarningVo"/> <include refid="selectDcWarningVo"/>
where id = #{id} where id = #{id}
</select> </select>

Loading…
Cancel
Save