Newer
Older
newfiber-termite / newfiber-termites / newfiber-termites-dataup / src / main / java / com / newfiber / termite / controller / TermiteController.java
@xiongkai xiongkai on 4 Jun 7 KB 设备状态同步接口
package com.newfiber.termite.controller;


import com.newfiber.common.core.enums.EBoolean;
import com.newfiber.common.core.utils.PageUtils;
import com.newfiber.common.core.web.controller.BaseController;
import com.newfiber.common.security.utils.SecurityUtils;
import com.newfiber.termite.domain.DeviceInfo;
import com.newfiber.termite.domain.dto.*;
import com.newfiber.termite.domain.request.*;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
import com.newfiber.termite.domain.response.DataUpResponse;
import com.newfiber.termite.domain.response.DeviceInfoStateSyncResponse;
import com.newfiber.termite.domain.response.TermiteInfoResponse;
import com.newfiber.termite.service.IDeviceInfoService;
import com.newfiber.termite.service.IProjectInfoService;
import com.newfiber.termite.service.ITermiteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import com.newfiber.common.core.web.domain.Result;
import com.newfiber.common.core.web.page.PageResult;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/termite")
@Api(value = "白蚁防治", tags = "白蚁防治页面接口")
public class TermiteController extends BaseController {

    @Resource
    private ITermiteService termiteService;

    @Resource
    private IProjectInfoService projectInfoService;

    @Resource
    private IDeviceInfoService deviceInfoService;

    /**
     * 白蚁防治数据接收
     */
    @PostMapping("/termiteDataup")
    //@RequiresPermissions("business:warningBriefing:list")
    @ApiOperation(value = "白蚁防治数据接收", position = 60)
    public Result<DataUpResponse> termiteDataup(TermiteDataUpRequest dataDto, MultipartFile image) throws Exception{

        return success(termiteService.termiteDataup(dataDto,image));
    }

    /**
     * 白蚁防治图片识别后数据上传
     */
    @PostMapping("/photoIdentify")
    //@RequiresPermissions("business:warningBriefing:list")
    @ApiOperation(value = "白蚁防治图片识别后数据上传", position = 60)
    public Result<String> photoIdentify(PhotoIdentifyDto dataDto, MultipartFile image) throws Exception{

        if("".equals(dataDto.getId())|| dataDto.getId()==null){
            return Result.error("参数:id 不能为空");
        }
        return success(termiteService.photoIdentify(dataDto,image));
    }

    /**
     */
    @PostMapping("/syncDeviceState")
    @ApiOperation(value = "同步设备状态信息", position = 60)
    public Result<DeviceInfoStateSyncResponse> syncDeviceState(DeviceInfoStateSyncRequest request) {
        return success(termiteService.syncDeviceState(request));
    }

    /**
     * 分页查询数据
     */
    @PostMapping("/querytermiteData")
    @ApiOperation(value = "分页查询数据", position = 60)
    public PageResult<List<TermiteInfoResponse>> querytermiteData(TermiteInfoQueryRequest request){
        if(!SecurityUtils.isAdmin(SecurityUtils.getUserId())){
            request.setProjectCodeList(projectInfoService.getUserProjectCodeList(SecurityUtils.getUserId()));
        }
        PageUtils.startPage();
        List<TermiteInfoResponse> list = termiteService.querytermiteData(request);
        return pageResult(list);
    }

    /**
     * 列表查询所有站点数据信息
     */
    @PostMapping("/querytermiteDataByList")
    @ApiOperation(value = "列表查询所有站点数据信息", position = 60)
    public Result<List<TermiteInfoResponse>> querytermiteDataByList(TermiteInfoQueryRequest request){
        List<TermiteInfoResponse> list = termiteService.querytermiteData(request);
        return success(list);
    }

    /**
     * 查询当前行数据
     */
    @PostMapping("/queryMonitorData")
    @ApiOperation(value = "查询当前行数据", position = 60)
    public Result<TermiteInfoResponse> queryMonitorData(TermiteHistoryQueryRequest request){
        TermiteInfoResponse result = termiteService.queryMonitorData(request);
        return success(result);
    }


    /**
     * 更新监测数据
     */
    @PostMapping("/editMonitorData")
    @ApiOperation(value = "更新监测数据", position = 60)
    public Result<Object> updateMonitorData(TermiteInfoUpdateyRequest request){
        return success(termiteService.updateMonitorData(request));
    }


    /**
     * 查询历史数据集合
     */
    @PostMapping("/queryhistoryData")
    @ApiOperation(value = "查询历史数据", position = 60)
    public PageResult<List<TermiteInfoResponse>> queryhistoryData(TermiteHistoryQueryRequest request){
        startPage();
        List<TermiteInfoResponse> list =termiteService.queryhistoryData(request);
        return pageResult(list);
    }

    /**
     * 新增站点
     */
    @PostMapping("/insertMonitorDevice")
    @ApiOperation(value = "新增站点", position = 60)
    public Result<Object> insertMonitorDevice(TermiteInfoSaveRequest request){
        return success(termiteService.insertMonitorDevice(request));
    }

    /**
     * 修改站点信息
     */
    @PostMapping("/updateMonitorDevice")
    @ApiOperation(value = "修改站点信息", position = 60)
    public Result<Object> updateMonitorDevice(@RequestBody DeviceInfoUpdateRequest request){
        return success(termiteService.updateMonitorDevice(request));
    }


    /**
     * 删除站点
     */
    @PostMapping("/removeMonitorDevice")
    @ApiOperation(value = "删除站点", position = 60)
    public Result<Object> removeMonitorDevice(String id){
        return success(termiteService.removeMonitorDevice(id));
    }


    /**
     * 更新模型初始值
     */
    @PostMapping("/updateModlefirstData")
    @ApiOperation(value = "更新模型初始值", position = 60)
    public Result<Object> updateModlefirstData(String sn){
        if("".equals(sn)|| sn==null){
            return Result.error("参数:sn 不能为空");
        }
        return success(termiteService.updateModlefirstData(sn));
    }


    /**
     * 查询施工单位数据
     */
    @PostMapping("/queryUnitdata")
    @ApiOperation(value = "查询施工单位数据", position = 60)
    public Result<UnitInfoDto> queryUnitdata(){
        return success(termiteService.queryUnitdata());
    }

    /**
     * 查询报警数据信息
     */
    @PostMapping("/queryAlarmdata")
    @ApiOperation(value = "查询报警数据信息", position = 60)
    public Result<List<DeviceInfo>> queryAlarmdata(@RequestBody TermiteInfoQueryRequest request){
        DeviceInfoQueryRequest deviceInfoQueryRequest = new DeviceInfoQueryRequest();
        deviceInfoQueryRequest.setProjectCode(request.getProjectCode());
        deviceInfoQueryRequest.setWarnFlag(EBoolean.True.getStringValue());
        return success(deviceInfoService.selectList(deviceInfoQueryRequest));
    }

    /**
     * 站点报警统计
     */
    @PostMapping("/querySnalarmStatistic")
    @ApiOperation(value = "站点报警统计", position = 60)
    public Result<List<SnAlarmStatisticDto>> querySnalarmStatistic(@RequestBody TermiteInfoQueryRequest request){
        return success(termiteService.querySnalarmStatistic(request.getProjectCode()));
    }


    /**
     * 查询天气实况
     */
    @PostMapping("/queryNowWeather")
    @ApiOperation(value = "获取当前天气实况", position = 60)
    public Result<Object> queryNowWeather(){
        return success(termiteService.queryNowWeather());
    }
}