package com.hxzkappboot.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageInfo;
import com.hxzkappboot.pojo.TbPersonAndDepartment;
import com.hxzkappboot.pojo.TbWarning;
import com.hxzkappboot.service.TbPersonService;
import com.hxzkappboot.service.TbWarningService;
import com.hxzkappboot.udp.Udp_Out;
import com.hxzkappboot.util.R;
import com.hxzkappboot.util.StatusCode;
import com.hxzkappboot.util.result;
import com.hxzkappboot.util.resultutil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.List;
/**
*
* 前端控制器
*
*
* @author wangfei
* @since 2024-03-08
*/
@RestController
//@RequestMapping("/")
public class TbWarningController {
@Autowired
TbWarningService tbWarningService;
@GetMapping("/api/wx/findwarning")
public R findAll(Page page, String objectid,String company) {
R response;
List ipage = tbWarningService.findAll(page,objectid,company);
response = new R(StatusCode.Success);
response.setData(ipage);
return response;
}
@GetMapping("/api/wx/findWarningNum")
public R findWarningNum(String company ) {
R response;
try {
response = new R(StatusCode.Success);
response.setData(tbWarningService.findWarningNum(company));
} catch (Exception e) {
response = new R(StatusCode.Fail.getCode(), e.getMessage());
}
return response;
}
@PostMapping("/api/wx/processingWarn")
public R processingWarn(@Valid @RequestBody TbWarning warning) {
// R response ;
// response = new R(StatusCode.Success);
// return response;
String xieyi = "BSTOCS1,DELLWARN," +warning.getObjectid()+","+warning.getType()+",END";
// String xieyi = "BSTOCS1,DELETEFENCE," + name + ",END";
Udp_Out.udp_to_cs(xieyi);
R response ;
response = new R(StatusCode.Success);
TbWarning gpsList =tbWarningService.processingWarn(warning);
response.setData(gpsList);
// List fenceList = new ArrayList();
// System.out.println(name);
// fenceList = tbFenceService.earlyWarning();
// TbWarning tbWarning = tbWarningService.findWarningid(warning.getId());
// response.setData(tbWarning);
return response;
}
@PostMapping("/api/wx/moreprocessingWarn")
public R moreprocessingWarn(@Valid @RequestBody TbWarning warning) {
// R response ;
// response = new R(StatusCode.Success);
// TbWarning gpsList =tbWarningService.processingWarn(warning);
// response.setData(gpsList);
// return response;
for (int i = 0; i < warning.getIds().size(); i++) {
TbWarning tbWarning = tbWarningService.findWarningid(warning.getIds().get(i));
String xieyi = "BSTOCS1,DELLWARN," +tbWarning.getObjectid()+","+tbWarning.getType()+",END";
// String xieyi = "BSTOCS1,DELETEFENCE," + name + ",END";
Udp_Out.udp_to_cs(xieyi);
}
R response ;
// List fenceList = new ArrayList();
// System.out.println(name);
// fenceList = tbFenceService.earlyWarning();
response = new R(StatusCode.Success);
// response.setData(fenceList);
return response;
}
}