zhaoxianglong
10 months ago
3 changed files with 104 additions and 16 deletions
@ -0,0 +1,63 @@ |
|||||
|
package com.zc.business.controller; |
||||
|
|
||||
|
import com.ruoyi.common.core.controller.BaseController; |
||||
|
import com.ruoyi.common.core.domain.AjaxResult; |
||||
|
import com.ruoyi.common.utils.uuid.IdUtils; |
||||
|
import com.zc.business.domain.DcWarning; |
||||
|
import com.zc.business.service.IDcWarningService; |
||||
|
import io.swagger.annotations.Api; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import javax.annotation.Resource; |
||||
|
import java.text.ParseException; |
||||
|
import java.text.SimpleDateFormat; |
||||
|
import java.util.Date; |
||||
|
import java.util.Map; |
||||
|
import java.util.Objects; |
||||
|
|
||||
|
/** |
||||
|
* License |
||||
|
* |
||||
|
* @author Athena-xiepufeng |
||||
|
*/ |
||||
|
@Api(tags = "扫码报警") |
||||
|
@RestController |
||||
|
@RequestMapping("/codeScanningAlarm") |
||||
|
public class CodeScanningAlarmController extends BaseController { |
||||
|
|
||||
|
@Resource |
||||
|
private IDcWarningService dcWarningService; |
||||
|
|
||||
|
/** |
||||
|
* 扫码报警事件回调函数 |
||||
|
* |
||||
|
* @param returnParameters 事件回参 |
||||
|
* @return 结果 |
||||
|
*/ |
||||
|
@PostMapping(value = "/event") |
||||
|
public AjaxResult codeScanningAlarmControllerEvent(@RequestBody Map<String, Object> returnParameters) { |
||||
|
DcWarning dcWarning = new DcWarning(); |
||||
|
//设置事件Id UUID无下划线格式32
|
||||
|
String uuid = IdUtils.fastSimpleUUID(); |
||||
|
dcWarning.setId(uuid); |
||||
|
dcWarning.setStakeMark(String.valueOf(returnParameters.get("stakeNum"))); |
||||
|
String roadCode = String.valueOf(returnParameters.get("roadCode")); |
||||
|
dcWarning.setDirection(Objects.equals(roadCode, "1") ? "3" : "1"); |
||||
|
String createTime = String.valueOf(returnParameters.get("createTime")); |
||||
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mmXXX"); |
||||
|
try { |
||||
|
dcWarning.setWarningTime(format.parse(createTime)); |
||||
|
} catch (ParseException e) { |
||||
|
dcWarning.setWarningTime(new Date()); |
||||
|
} |
||||
|
dcWarning.setCreateTime(new Date()); |
||||
|
int warningType = Integer.parseInt(String.valueOf(returnParameters.get("accidentType"))) >= 4 ? 10 : 11; |
||||
|
dcWarning.setWarningType(warningType); |
||||
|
String warningTitle = "济荷高速:" + (Objects.equals(roadCode, "1") ? "济南方向" : "菏泽方向") + "发生" + (warningType == 10 ? "交通事故事件" : "车辆故障事件"); |
||||
|
dcWarning.setWarningTitle(warningTitle); |
||||
|
dcWarning.setOtherConfig(returnParameters.toString()); |
||||
|
dcWarning.setWarningSource(5); |
||||
|
dcWarning.setWarningState(1); |
||||
|
return AjaxResult.success(dcWarningService.insertDcWarning(dcWarning)); |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue