医院废弃物信息化管理平台
“mitao”
2026-01-14 ce8e86e7045a6eadc2f06d3cd1af90d22b04fdd0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package cn.besteam.modules.api.controller;
 
import cn.besteam.common.api.vo.Result;
import cn.besteam.common.aspect.annotation.OpenApi;
import cn.besteam.common.constant.CommonConstant;
import cn.besteam.common.constant.ErrorCode;
import cn.besteam.common.exception.BusinessException;
import cn.besteam.modules.medical.entity.MwAppVersion;
import cn.besteam.modules.medical.entity.MwDeviceAgent;
import cn.besteam.modules.medical.entity.MwDeviceAgentDevice;
import cn.besteam.modules.medical.service.IMwAppVersionService;
import cn.besteam.modules.medical.service.IMwDeviceAgentDeviceService;
import cn.besteam.modules.medical.service.IMwDeviceAgentService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.List;
 
@RestController
@RequestMapping("/api/system")
@Api(value = "系统相关")
public class ApiSystemController {
 
    @Autowired
    private IMwAppVersionService mwAppVersionService;
 
    @Autowired
    private IMwDeviceAgentDeviceService mwDeviceAgentDeviceService;
 
    @Autowired
    private IMwDeviceAgentService mwDeviceAgentService;
 
    @ApiOperation(value = "获取最新的APP版本")
    @OpenApi
    @GetMapping("/getLatestVersion")
    public Result<?> getLatestVersion() {
 
        List<MwAppVersion> list = mwAppVersionService.list(new QueryWrapper<MwAppVersion>().lambda().orderByDesc(MwAppVersion::getVersion));
        if (CollectionUtils.isNotEmpty(list)) {
            return Result.ok(list.get(0));
        }
        return Result.ok(null);
    }
 
    @ApiOperation(value = "获取设备信息,返回null则不可用")
    @OpenApi
    @GetMapping("/getDeviceInfo")
    public Result<?> getDeviceInfo(@RequestParam("sn") String sn) {
 
        MwDeviceAgentDevice device = mwDeviceAgentDeviceService.getOne(new QueryWrapper<MwDeviceAgentDevice>().lambda().eq(MwDeviceAgentDevice::getSn, sn).eq(MwDeviceAgentDevice::getStatus, CommonConstant.STATUS_NORMAL));
        if (device != null) {
            MwDeviceAgent mwDeviceAgent = mwDeviceAgentService.getById(device.getDeviceAgentId());
            return Result.ok(mwDeviceAgent);
        } else {
            Integer deviceValidateStatus = mwDeviceAgentDeviceService.getDeviceValidateStatus();
            if (deviceValidateStatus.equals(1)) {
                throw new BusinessException(ErrorCode.ERR_500, "未授权设备");
            } else {
                return Result.ok(new MwDeviceAgent().setDescription("").setName("").setId(-1));
            }
        }
    }
 
}