医院废弃物信息化管理平台
“mitao”
2025-12-25 0242c8ae596f44427cd23d38f637bf987a4de0bf
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
package cn.besteam.modules.medical.controller;
 
import cn.besteam.common.api.vo.Result;
import cn.besteam.common.aspect.annotation.AutoLog;
import cn.besteam.common.aspect.annotation.OpenApi;
import cn.besteam.common.constant.ErrorCode;
import cn.besteam.common.exception.BusinessException;
import cn.besteam.modules.medical.biz.MonitorDeviceApiNewService;
import cn.besteam.modules.medical.dto.MwDeviceAgentDeviceDTO;
import cn.besteam.modules.medical.dto.MwDeviceAgentDeviceSaveDTO;
import cn.besteam.modules.medical.entity.MwDeviceAgent;
import cn.besteam.modules.medical.entity.MwDeviceAgentDevice;
import cn.besteam.modules.medical.service.IMwDeviceAgentDeviceService;
import cn.besteam.modules.medical.service.IMwDeviceAgentService;
import cn.besteam.modules.medical.vo.MwDeviceAgentDeviceAddBatchVO;
import cn.besteam.modules.medical.vo.MwDeviceAgentDeviceExcelVO;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.*;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.io.IOException;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
 
/**
 * @Title: Controller
 * @Description: 设备代理商-设备
 * @author: besteam
 * @date: 2020-04-25
 * @version: V1.0
 */
@RestController
@RequestMapping("/medical/mwDeviceAgentDevice")
@Slf4j
@Api(description = "设备代理商-设备")
public class MwDeviceAgentDeviceController {
 
    @Autowired
    private IMwDeviceAgentService mwDeviceAgentService;
 
    @Autowired
    private IMwDeviceAgentDeviceService mwDeviceAgentDeviceService;
    /**
     * 视频设备
     */
    @Autowired
    private MonitorDeviceApiNewService monitorDeviceApiNewService;
 
    /**
     * 分页列表查询
     *
     * @param name
     * @param pageNo
     * @param pageSize
     * @return
     */
    @GetMapping(value = "/list")
    @ApiOperation(value = "获取设备代理商-设备数据列表", notes = "获取所有设备代理商-设备数据列表", produces = "application/json")
    public Result<IPage<MwDeviceAgentDevice>> queryPageList(String name, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
 
        return Result.ok(mwDeviceAgentDeviceService.getDeviceList(name, pageNo, pageSize));
    }
 
    @PostMapping("/addBatch")
    @ApiOperation(value = "批量添加设备", notes = "批量添加设备", produces = "application/json")
    public Result<MwDeviceAgentDeviceAddBatchVO> addBatch(@RequestBody MwDeviceAgentDeviceSaveDTO dto) {
 
        MwDeviceAgent mwDeviceAgent = mwDeviceAgentService.getById(dto.getDeviceAgentId());
        if (mwDeviceAgent == null) {
            throw new BusinessException(ErrorCode.MW_DEVICE_AGENT_NOT_FOUND);
        }
        return Result.ok(mwDeviceAgentDeviceService.addBatch(dto.getDeviceAgentId(), dto.getSns()));
    }
     /**
      * 编辑
      *
      * @param mwDeviceAgentDevice
      * @return
      */
     @PostMapping(value = "/edit")
     @AutoLog(value = "编辑设备代理商-设备")
     @ApiOperation(value = "编辑设备代理商-设备", notes = "编辑设备代理商-设备", produces = "application/json")
     public Result<MwDeviceAgentDevice> edit(@RequestBody MwDeviceAgentDevice mwDeviceAgentDevice) {
 
         Result<MwDeviceAgentDevice> result = new Result<MwDeviceAgentDevice>();
         MwDeviceAgentDevice mwDeviceAgentDeviceEntity = mwDeviceAgentDeviceService.getById(mwDeviceAgentDevice.getId());
         if (mwDeviceAgentDeviceEntity == null) {
             result.error500("未找到对应实体");
         } else {
             boolean ok = mwDeviceAgentDeviceService.updateById(mwDeviceAgentDeviceEntity);
             if (ok) {
                 result.success("修改成功!");
             }
         }
         return result;
     }
 
    /**
     * 通过id删除
     *
     * @param dto
     * @return
     */
    @PostMapping(value = "/delete")
    @AutoLog(value = "删除设备代理商-设备")
    @ApiOperation(value = "删除设备代理商-设备", notes = "删除设备代理商-设备", produces = "application/json")
    public Result<Boolean> delete(@RequestBody MwDeviceAgentDeviceDTO dto) {
 
        Result<Boolean> result = new Result<Boolean>();
        MwDeviceAgentDevice mwDeviceAgentDevice = mwDeviceAgentDeviceService.getById(dto.getId());
        if (mwDeviceAgentDevice == null) {
            result.error500("未找到对应实体");
        } else {
            boolean ok = mwDeviceAgentDeviceService.removeById(dto.getId());
            if (ok) {
                result.success("删除成功!");
            }
        }
        return result;
    }
 
    /**
     * 批量删除
     *
     * @param dto
     * @return
     */
    @PostMapping(value = "/deleteBatch")
    @AutoLog(value = "批量删除设备代理商-设备")
    @ApiOperation(value = "批量删除设备代理商-设备", notes = "批量删除设备代理商-设备", produces = "application/json")
    public Result<Boolean> deleteBatch(@RequestBody MwDeviceAgentDeviceDTO dto) {
 
        Result<Boolean> result = new Result<Boolean>();
        if (dto.getIds() == null || "".equals(dto.getIds().trim())) {
            result.error500("参数不识别!");
        } else {
            this.mwDeviceAgentDeviceService.removeByIds(Arrays.asList(dto.getIds().split(",")));
            result.success("删除成功!");
        }
        return result;
    }
 
    /**
     * 移动
     *
     * @param dto
     * @return
     */
    @PostMapping(value = "/move")
    @AutoLog(value = "移动设备代理商-设备")
    @ApiOperation(value = "移动设备代理商-设备", notes = "移动设备代理商-设备", produces = "application/json")
    public Result<Boolean> move(@RequestBody MwDeviceAgentDeviceDTO dto) {
 
        MwDeviceAgent mwDeviceAgent = mwDeviceAgentService.getById(dto.getDeviceAgentId());
        if (mwDeviceAgent == null) {
            throw new BusinessException(ErrorCode.MW_DEVICE_AGENT_NOT_FOUND);
        }
        return Result.ok(mwDeviceAgentDeviceService.move(dto.getId(), dto.getDeviceAgentId()));
    }
 
    /**
     * 批量移动
     *
     * @param dto
     * @return
     */
    @PostMapping(value = "/moveBatch")
    @AutoLog(value = "批量移动设备代理商-设备")
    @ApiOperation(value = "批量移动设备代理商-设备", notes = "批量移动设备代理商-设备", produces = "application/json")
    public Result<Boolean> moveBatch(@RequestBody MwDeviceAgentDeviceDTO dto) {
 
        MwDeviceAgent mwDeviceAgent = mwDeviceAgentService.getById(dto.getDeviceAgentId());
        if (mwDeviceAgent == null) {
            throw new BusinessException(ErrorCode.MW_DEVICE_AGENT_NOT_FOUND);
        }
        Result<Boolean> result = new Result<Boolean>();
        if (dto.getIds() == null || "".equals(dto.getIds().trim()) || dto.getDeviceAgentId() == null) {
            result.error500("参数不识别!");
        } else {
            this.mwDeviceAgentDeviceService.moveBatch(dto.getIds(), dto.getDeviceAgentId());
            result.success("移动成功!");
        }
        return result;
    }
 
    /**
     * 启用、禁用
     *
     * @param dto
     * @return
     */
    @PostMapping(value = "/updateStatus")
    @AutoLog(value = "启用、禁用设备代理商-设备")
    @ApiOperation(value = "启用、禁用设备代理商-设备", notes = "启用、禁用设备代理商-设备", produces = "application/json")
    public Result<Boolean> updateState(@RequestBody MwDeviceAgentDeviceDTO dto) {
 
        return Result.ok(mwDeviceAgentDeviceService.updateStatus(dto.getId(), dto.getStatus()));
    }
 
    /**
     * 批量启用、禁用
     *
     * @param dto
     * @return
     */
    @PostMapping(value = "/updateStatusBatch")
    @AutoLog(value = "批量启用、禁用设备代理商-设备")
    @ApiOperation(value = "批量启用、禁用设备代理商-设备", notes = "批量启用、禁用设备代理商-设备", produces = "application/json")
    public Result<Boolean> updateStatusBatch(@RequestBody MwDeviceAgentDeviceDTO dto) {
 
        Result<Boolean> result = new Result<Boolean>();
        if (dto.getIds() == null || "".equals(dto.getIds().trim()) || dto.getStatus() == null) {
            result.error500("参数不识别!");
        } else {
            this.mwDeviceAgentDeviceService.updateStatusBatch(dto.getIds(), dto.getStatus());
            result.success("修改成功!");
        }
        return result;
    }
 
    @OpenApi
    @GetMapping("/export")
    @ApiOperation(value = "导出", notes = "导出")
    public void export(HttpServletResponse response, Integer deviceAgentId) throws UnsupportedEncodingException {
 
        List<MwDeviceAgentDeviceExcelVO> list = mwDeviceAgentDeviceService.getDeviceExcelList(deviceAgentId);
        //
        ExcelWriter excelWriter = ExcelUtil.getWriter(true);
        excelWriter.renameSheet("硬件特征码导出");
        excelWriter.setColumnWidth(0, 20);
        excelWriter.setColumnWidth(1, 20);
        excelWriter.setColumnWidth(2, 20);
        excelWriter.setColumnWidth(3, 20);
        excelWriter.addHeaderAlias("name", "厂商");
        excelWriter.addHeaderAlias("sn", "特征码");
        excelWriter.addHeaderAlias("statusStr", "状态");
        excelWriter.addHeaderAlias("createTime", "创建时间");
        excelWriter.write(list, true);
        //
        response.setContentType("application/octet-stream;charset=utf-8");
        String fileName = "硬件特征码导出";
        response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8") + ".xlsx");
        // response.setHeader("Content-Disposition", "attachment;");
        ServletOutputStream out = null;
        try {
            out = response.getOutputStream();
            excelWriter.flush(out, true);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (out != null) {
                try {
                    out.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            excelWriter.close();
        }
    }
 
    @GetMapping("/getDeviceValidateStatus")
    @ApiOperation(value = "获取特征码校验开关", notes = "获取特征码校验开关")
    public Result<Integer> getDeviceValidateStatus() {
 
        return Result.ok(mwDeviceAgentDeviceService.getDeviceValidateStatus());
    }
 
    @PostMapping("/setDeviceValidateStatus")
    @ApiOperation(value = "设置特征码校验开关", notes = "设置特征码校验开关")
    public Result<Boolean> setDeviceValidateStatus(@RequestBody MwDeviceAgentDeviceValidateStatusDTO dto) {
 
        return Result.ok(mwDeviceAgentDeviceService.setDeviceValidateStatus(dto.getStatus()));
    }
 
    @Data
    @ApiModel
    private static class MwDeviceAgentDeviceValidateStatusDTO implements Serializable {
 
        @NotNull(message = "状态不能为空")
        @Min(value = 0, message = "状态区间[0,1]")
        @Max(value = 1, message = "状态区间[0,1]")
        @ApiModelProperty("1启动0禁用")
        private Integer status;
 
    }
 
    @GetMapping("/getToken")
    @ApiOperation(value = "获取视频服务器token", notes = "获取视频服务器token")
    public Result<String> getToken() {
        return Result.ok(monitorDeviceApiNewService.getJSession(1));
    }
 
    @GetMapping("/getDeviceList")
    @ApiOperation(value = "获取视频服务器设备列表", notes = "获取视频服务器设备列表")
    public Result<List<String>> getDeviceList() {
        return Result.ok(monitorDeviceApiNewService.getDeviceList());
    }
 
    @GetMapping("/getDeviceUrl")
    @ApiOperation(value = "获取视频服务器设备播放路径", notes = "获取视频服务器设备播放路径")
    public Result<Map<String,Object>> getDeviceUrl(String id,Integer channelNum) {
        return Result.ok(monitorDeviceApiNewService.getDeviceUrl(id,channelNum));
    }
 
    @GetMapping("/getChannelList")
    @ApiOperation(value = "查询设备通道列表(新)", notes = "查询设备通道列表(新)")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "serial", value = "设备编号", required = true, dataType = "String", format = "query")
    })
    public Result<List<Map<String,String>>> getChannelList(String serial) {
        return Result.ok(monitorDeviceApiNewService.getChannelList(serial));
    }
 
    @GetMapping("/getPlaybackRecordlist")
    @ApiOperation(value = "查询通道录像列表(新)", notes = "查询通道录像列表(新)")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "serial", value = "设备编号", required = true, dataType = "String", format = "query"),
            @ApiImplicitParam(name = "channel", value = "通道号", required = true, dataType = "Integer", format = "query"),
            @ApiImplicitParam(name = "starttime", value = "开始时间(格式:YYYY-MM-DDTHH:mm:ss 如:2023-04-25T08:00:00)", required = true, dataType = "String", format = "query"),
            @ApiImplicitParam(name = "endtime", value = "结束时间(格式:YYYY-MM-DDTHH:mm:ss 如:2023-04-25T08:00:00)", required = false, dataType = "String", format = "query")
    })
    public Result<List<Map<String,String>>> getPlaybackRecordlist(String serial,Integer channel,String starttime,String endtime) {
        return Result.ok(monitorDeviceApiNewService.getPlaybackRecordlist(serial,channel,starttime,endtime));
    }
    @GetMapping("/playbackStart")
    @ApiOperation(value = "开始回放(新)", notes = "开始回放(新)")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "serial", value = "设备编号", required = true, dataType = "String", format = "query"),
            @ApiImplicitParam(name = "channel", value = "通道号", required = true, dataType = "Integer", format = "query"),
            @ApiImplicitParam(name = "starttime", value = "开始时间(格式:YYYY-MM-DDTHH:mm:ss 如:2023-04-25T08:00:00)", required = true, dataType = "String", format = "query"),
            @ApiImplicitParam(name = "endtime", value = "结束时间(格式:YYYY-MM-DDTHH:mm:ss 如:2023-04-25T08:00:00)", required = false, dataType = "String", format = "query")
    })
    public Result<Map<String,Object>> playbackStart(String serial,Integer channel,String starttime,String endtime) {
        return Result.ok(monitorDeviceApiNewService.playbackStart(serial,channel,starttime,endtime));
    }
 
    @GetMapping("/playbackStop")
    @ApiOperation(value = "回放流停止(新)", notes = "回放流停止(新)")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "streamID", value = "流ID", required = true, dataType = "String", format = "query")
    })
    public Result<Map<String,Object>> playbackStop(String streamID) {
        return Result.ok(monitorDeviceApiNewService.playbackStop(streamID));
    }
 
}