|
@@ -0,0 +1,131 @@
|
|
|
+package com.care.operate.controller;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.care.bms.service.DeviceService;
|
|
|
+import com.care.common.annotation.Permission;
|
|
|
+import com.care.common.entity.CareDevice;
|
|
|
+import com.care.common.exception.BDException;
|
|
|
+import com.care.common.service.CareDeviceService;
|
|
|
+import com.care.common.util.PageResult;
|
|
|
+import com.care.common.util.Result;
|
|
|
+import com.care.common.util.WebPageUtils;
|
|
|
+import com.care.common.vo.PageReqVO;
|
|
|
+import com.care.common.vo.UserLogindConvertVO;
|
|
|
+import com.care.common.vo.device.DeviceVO;
|
|
|
+
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Author: stw
|
|
|
+ * @Date: 2021/5/26
|
|
|
+ * @Desc:
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@Api(value = "OpDeviceController", tags = { "运营平台-设备管理" })
|
|
|
+@Slf4j
|
|
|
+@RequestMapping("/operate/device")
|
|
|
+@Permission
|
|
|
+public class OpDeviceController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DeviceService deviceService;
|
|
|
+ @Autowired
|
|
|
+ private CareDeviceService careDeviceService;
|
|
|
+
|
|
|
+ @GetMapping("/list")
|
|
|
+ @ApiOperation(value = "设备列表分页--四期期新增(和管理后台一样)")
|
|
|
+ @ApiImplicitParams(value = {
|
|
|
+ @ApiImplicitParam(paramType = "query", name = "stationId", value = "服务站ID"),
|
|
|
+ @ApiImplicitParam(paramType = "query", name = "devCode", value = "设备编码"),
|
|
|
+ @ApiImplicitParam(paramType = "query", name = "activeStatus", value = "激活状态"),
|
|
|
+ @ApiImplicitParam(paramType = "query", name = "chambName", value = "关联管家"),
|
|
|
+ @ApiImplicitParam(paramType = "query", name = "status", value = "状态"),
|
|
|
+ @ApiImplicitParam(paramType = "query", name = "houseAddr", value = "地址"),
|
|
|
+ @ApiImplicitParam(paramType = "query", name = "chambId", value = "管家ID"),
|
|
|
+ @ApiImplicitParam(paramType = "query", name = "memberId", value = "用户ID"),
|
|
|
+ })
|
|
|
+ public PageResult<List<DeviceVO>> listDevice(HttpServletRequest request, @RequestHeader(value = "token") String token,
|
|
|
+ @RequestParam(value = "stationId", required = false) Long stationId,
|
|
|
+ @RequestParam(value = "devCode", required = false) String devCode,
|
|
|
+ @RequestParam(value = "activeStatus", required = false) String activeStatus,
|
|
|
+ @RequestParam(value = "chambName", required = false) String chambName,
|
|
|
+ @RequestParam(value = "status", required = false) String status,
|
|
|
+ @RequestParam(value = "houseAddr", required = false) String houseAddr,
|
|
|
+ @RequestParam(value = "chambId", required = false) Long chambId,
|
|
|
+ @RequestParam(value = "memberId", required = false) Long memberId,
|
|
|
+ PageReqVO pageReqVo){
|
|
|
+ try {
|
|
|
+ UserLogindConvertVO loginUser = WebPageUtils.getCurrentLoginedUser(request);
|
|
|
+ IPage<DeviceVO> pageResponse = this.deviceService.listDevice(stationId,devCode,activeStatus,chambName,status,houseAddr,chambId,memberId,loginUser ,pageReqVo);
|
|
|
+ return PageResult.success(pageResponse.getRecords(),pageResponse.getCurrent(),pageResponse.getSize(),pageResponse.getTotal());
|
|
|
+ }catch (BDException e) {
|
|
|
+ log.error("设备列表查询-分页列表出现异常",e);
|
|
|
+ return PageResult.error(e.getMessage());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("设备管理: 设备列表查询出现异常",e);
|
|
|
+ return PageResult.error( "获取列表失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/listDeviceNonStation")
|
|
|
+ @ApiOperation(value = "查询站点为空的设备列表分页--四期期新增")
|
|
|
+ public PageResult<List<DeviceVO>> listDeviceNonStation(HttpServletRequest request, @RequestHeader(value = "token") String token,
|
|
|
+ PageReqVO pageReqVo){
|
|
|
+ try {
|
|
|
+ UserLogindConvertVO loginUser = WebPageUtils.getCurrentLoginedUser(request);
|
|
|
+ IPage<DeviceVO> pageResponse = this.deviceService.listDeviceNonStation(loginUser ,pageReqVo);
|
|
|
+ return PageResult.success(pageResponse.getRecords(),pageResponse.getCurrent(),pageResponse.getSize(),pageResponse.getTotal());
|
|
|
+ }catch (BDException e) {
|
|
|
+ log.error("设备列表查询-分页列表出现异常",e);
|
|
|
+ return PageResult.error(e.getMessage());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("设备管理: 设备列表查询出现异常",e);
|
|
|
+ return PageResult.error( "获取列表失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/distributeDevice")
|
|
|
+ @ApiOperation(value = "分配设备(对象list中只设置stationId和设备的id) --四期新增 ")
|
|
|
+ public Result<Object> distributeDevice( @RequestHeader("token") String token,
|
|
|
+ @RequestBody List<DeviceVO> vos){
|
|
|
+ try {
|
|
|
+
|
|
|
+ if(CollUtil.isEmpty(vos)){
|
|
|
+ return Result.error("分配设备列表不能为空!");
|
|
|
+ }
|
|
|
+ List<CareDevice> careDevices = new ArrayList<>();
|
|
|
+ for (DeviceVO vo : vos){
|
|
|
+ CareDevice careDevice = new CareDevice();
|
|
|
+ BeanUtil.copyProperties(vo,careDevice);
|
|
|
+ careDevices.add(careDevice);
|
|
|
+ }
|
|
|
+
|
|
|
+ this.careDeviceService.updateBatchById(careDevices);
|
|
|
+
|
|
|
+ return Result.success("分配设备成功!");
|
|
|
+ }catch (BDException e) {
|
|
|
+ log.error("分配设备-出现异常",e);
|
|
|
+ return Result.error(e.getMessage());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("设备管理: 分配设备出现异常",e);
|
|
|
+ return Result.error("分配设备失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|