|
@@ -0,0 +1,51 @@
|
|
|
+package com.sooka.sponest.lawenforcement.device.controller;
|
|
|
+
|
|
|
+import com.ruoyi.common.core.web.controller.BaseController;
|
|
|
+import com.ruoyi.common.core.web.domain.AjaxResult;
|
|
|
+import com.sooka.sponest.lawenforcement.device.domain.DeviceBO;
|
|
|
+import com.sooka.sponest.lawenforcement.device.service.IDeviceService;
|
|
|
+import com.sooka.sponest.lawenforcement.record.service.ILawenforcementRecordService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author LG
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/device")
|
|
|
+public class DeviceController extends BaseController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ILawenforcementRecordService recordService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IDeviceService deviceService;
|
|
|
+
|
|
|
+ @PostMapping("/open")
|
|
|
+ public AjaxResult open(@RequestBody DeviceBO bo) {
|
|
|
+ deviceService.open(bo);
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 可以添加其他方法来停止定时任务,例如:
|
|
|
+ @PostMapping("/stop/{deviceCode}")
|
|
|
+ public AjaxResult stopDevice(@PathVariable String deviceCode) {
|
|
|
+ deviceService.cancelTask(deviceCode);
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/getTaskList")
|
|
|
+ public AjaxResult getTaskList(){
|
|
|
+ return AjaxResult.success(deviceService.getTaskList());
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/close")
|
|
|
+ public AjaxResult close(@RequestBody DeviceBO bo){
|
|
|
+ System.out.println(" 设备关闭 ");
|
|
|
+ //设备关机先尝试删除定时任务
|
|
|
+ deviceService.cancelTask(bo.getDeviceCode());
|
|
|
+ //设置任务结束时间和任务状态为完成
|
|
|
+ recordService.updateRecordLogEndTime(bo);
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+}
|