Newer
Older
newfiber-termite / newfiber-termites / newfiber-termites-dataup / src / main / java / com / newfiber / termite / controller / TermiteController.java
@xiongkai xiongkai 7 days ago 8 KB bug修复
package com.newfiber.termite.controller;


import com.newfiber.common.core.enums.EBoolean;
import com.newfiber.common.core.utils.poi.ExcelUtil;
import com.newfiber.common.core.web.controller.BaseController;
import com.newfiber.common.core.web.domain.Result;
import com.newfiber.common.core.web.page.PageResult;
import com.newfiber.common.security.utils.SecurityUtils;
import com.newfiber.termite.domain.DeviceInfo;
import com.newfiber.termite.domain.dto.PhotoIdentifyDto;
import com.newfiber.termite.domain.dto.SnAlarmStatisticDto;
import com.newfiber.termite.domain.dto.TermiteDataUpRequest;
import com.newfiber.termite.domain.dto.UnitInfoDto;
import com.newfiber.termite.domain.request.DeviceInfoUpdateRequest;
import com.newfiber.termite.domain.request.TermiteHistoryQueryRequest;
import com.newfiber.termite.domain.request.TermiteInfoQueryRequest;
import com.newfiber.termite.domain.request.TermiteInfoSaveRequest;
import com.newfiber.termite.domain.request.TermiteInfoUpdateyRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoQueryRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
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 java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@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()));
        }
        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("/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();
        PageResult<List<TermiteInfoResponse>> result =termiteService.queryhistoryData(request);
        return result;
    }


    @PostMapping("/export")
    @ApiOperation(value = "查询历史数据导出excel", position = 60)
    public void export(HttpServletResponse response, TermiteHistoryQueryRequest request){
        List<TermiteInfoResponse> result =termiteService.queryhistoryDataList(request);
        ExcelUtil<TermiteInfoResponse> util = new ExcelUtil<TermiteInfoResponse>(TermiteInfoResponse.class);
        util.exportExcel(response, result, request.getSn()+"历史站点");
    }


    /**
     * 新增站点
     */
    @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());
    }

    /**
     */
    @PostMapping("/transferMySql2Mongo")
    @ApiOperation(value = "termiteService.transferMySql2Mongo()", position = 60)
    public Result<String> transferMySql2Mongo(){
        termiteService.transferMySql2Mongo();
        return success();
    }

    /**
     * 列表查询告警记录
     */
    @GetMapping("/reverseDebug")
    @ApiOperation(value = "开启调试", position = 60)
    public Result<Boolean> reverseDebug() {
        return success(termiteService.reverseDebug());
    }

}