燕山石化溯源三维电子沙盘-【后端】-服务
1
13693261870
2024-11-13 2f55cebbad3dea187a5f91d16ec80a9677dab699
src/main/java/com/yssh/controller/SuYuanController.java
@@ -1,7 +1,9 @@
package com.yssh.controller;
import cn.hutool.core.date.DateTime;
import com.yssh.entity.*;
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;
@@ -25,13 +27,6 @@
import javax.annotation.Resource;
/**
 * @author lishijia
 * @ClassName Yssh2dreliController
 * @Description Yssh2dreliController
 * @date 2022/12/3 21:21
 * @Version 1.0
 */
@Api(tags="溯源信息")
@RestController
@RequestMapping("/suYuan")
@@ -45,6 +40,9 @@
    @Resource
    private VocValsService vocValsService;
    @Resource
    private SocketService socketService;
    private final static SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHH");
@@ -196,11 +194,36 @@
    }
    @ApiOperation(value = "根据名称查询溯源ID", notes = "根据名称查询溯源ID")
    @ApiOperationSupport(order = 16)
    @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());
        }
    }
}