燕山石化溯源三维电子沙盘-【后端】-服务
1
13693261870
2024-11-13 2f55cebbad3dea187a5f91d16ec80a9677dab699
src/main/java/com/yssh/controller/SuYuanController.java
@@ -1,8 +1,11 @@
package com.yssh.controller;
import cn.hutool.core.date.DateTime;
import com.yssh.entity.*;
import com.yssh.service.ICommonService;
import com.yssh.service.CommonService;
import com.yssh.service.SocketService;
import com.yssh.service.VocValsService;
import com.yssh.utils.DateUtils;
import com.yssh.utils.StringUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -11,7 +14,6 @@
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@@ -20,31 +22,27 @@
import org.springframework.web.bind.annotation.RestController;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.yssh.service.ISuYuanService;
import com.yssh.service.SuYuanService;
import com.yssh.utils.Result;
import javax.annotation.Resource;
/**
 * @author lishijia
 * @ClassName Yssh2dreliController
 * @Description Yssh2dreliController
 * @date 2022/12/3 21:21
 * @Version 1.0
 */
@Api(tags="溯源信息")
@RestController
@RequestMapping("/suYuan")
@SuppressWarnings("rawtypes")
public class SuYuanController {
    @Resource
    private ICommonService commonService;
    private CommonService commonService;
    @Resource
    private ISuYuanService suYuanService;
    private SuYuanService suYuanService;
    @Resource
    private VocValsService vocValsService;
    @Resource
    private SocketService socketService;
    private final static SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHH");
@@ -147,32 +145,36 @@
    @ApiOperationSupport(order = 11)
    @GetMapping("/selectVocByTime")
    public Result selectVocByTime(@RequestParam(value = "date", required = true) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date date) {
        List<VocVals> list = vocValsService.selectByTime(format.format(date));
        String time = DateUtils.getYyyyMmDdHhMmSs(date);
        List<VocVals> list = vocValsService.selectByTime(time);
        return Result.OK(list);
    }
    @ApiOperation(value = "根据X,Y值查询地址", notes = "根据X,Y值查询地址")
    @ApiOperation(value = "根据ID和日期查询溯源46表", notes = "根据ID和日期查询溯源46表")
    @ApiOperationSupport(order = 12)
    @GetMapping("/selectCoords")
    public Result selectVocByTime(@RequestParam(value = "x", required = false) Integer x, @RequestParam(value = "y", required = false) Integer y) {
        return Result.OK(vocValsService.selectCoords(x, y));
    }
    @ApiOperation(value = "根据X、Y值查询矩形框", notes = "根据X、Y值查询矩形框")
    @ApiOperationSupport(order = 13)
    @GetMapping("/selectRects")
    public Result selectRects(@RequestParam(value = "x[]", required = true) Double[] x, @RequestParam(value = "y[]", required = true) Double[] y) {
        if (null == x || null == y || x.length == 0 || x.length != y.length) return Result.OK(null);
        return Result.OK(suYuanService.selectRects(x, y));
    @GetMapping("/selectSuYuan46ById")
    public Result selectSuYuan46ById(@RequestParam(value = "id", required = true) String id, @RequestParam(value = "date", required = true) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date date) {
        return Result.OK(suYuanService.selectSuYuan46ById(id, date));
    }
    @ApiOperation(value = "根据ID和日期查询溯源700表", notes = "根据ID和日期查询溯源700表")
    @ApiOperationSupport(order = 14)
    @ApiOperationSupport(order = 13)
    @GetMapping("/selectSuYuan700ById")
    public Result selectSuYuan700ById(@RequestParam(value = "id", required = true) String id, @RequestParam(value = "date", required = true) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date date) {
        return Result.OK(suYuanService.selectSuYuan700ById(id, date));
    }
    @ApiOperation(value = "根据X,Y值查询地址", notes = "根据X,Y值查询地址")
    @ApiOperationSupport(order = 14)
    @GetMapping("/selectCoords")
    public Result selectCoords(@RequestParam(value = "x") Integer x, @RequestParam(value = "y") Integer y, @RequestParam(value = "isSuYuan") Integer isSuYuan) {
        if (isSuYuan < 1) {
            x = x / 10;
            y = y / 10;
        }
        return Result.OK(vocValsService.selectCoords(x, y));
    }
    @ApiOperation(value = "根据经纬度查询地名", notes = "根据经纬度查询地名")
@@ -181,4 +183,47 @@
    public Result selectAddrByXY(@RequestParam(value = "x", required = true) double x, @RequestParam(value = "y", required = true) double y) {
        return Result.OK(suYuanService.selectAddrByXY(x, y));
    }
    @ApiOperation(value = "根据X、Y值查询矩形框", notes = "根据X、Y值查询矩形框")
    @ApiOperationSupport(order = 16)
    @GetMapping("/selectRects")
    public Result selectRects(@RequestParam(value = "x[]", required = true) Double[] x, @RequestParam(value = "y[]", required = true) Double[] y) {
        if (null == x || null == y || x.length == 0 || x.length != y.length) return Result.OK(null);
        return Result.OK(suYuanService.selectRects(x, y));
    }
    @ApiOperation(value = "根据名称查询溯源ID", notes = "根据名称查询溯源ID")
    @ApiOperationSupport(order = 17)
    @GetMapping("/selectSuYuanIdByName")
    public Result selectSuYuanIdByName(@RequestParam(value = "name") String name) {
        if (null == name || name.length() == 0) return Result.OK(null);
        return Result.OK(suYuanService.selectSuYuanIdByName(name));
    }
    @ApiOperation(value = "根据ID查询快速溯源")
    @ApiOperationSupport(order = 18)
    @GetMapping("/selectFastById")
    public Result selectFastById(@RequestParam(value = "id") String id, @RequestParam(value = "date", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date date) {
        if (StringUtils.isEmpty(id)) return Result.OK(null);
        if (null == date) date = DateTime.now();
        return Result.OK(suYuanService.selectFastById(id, date));
    }
    @ApiOperation(value = "发送消息")
    @ApiOperationSupport(order = 19)
    @GetMapping("/sendMsg")
    public Result sendMsg(@RequestParam(value = "msg") String msg) {
        if (StringUtils.isEmpty(msg)) return Result.error("消息不能为空");
        try {
            String rs = socketService.sendMsg(msg);
            return Result.OK(rs);
        } catch (Exception ex) {
            return Result.error(ex.getMessage());
        }
    }
}