|  |  |  | 
|---|
|  |  |  | import com.doumee.core.model.PageWrap; | 
|---|
|  |  |  | import com.doumee.core.utils.Constants; | 
|---|
|  |  |  | import com.doumee.dao.business.model.YwDevice; | 
|---|
|  |  |  | import com.doumee.dao.business.vo.YwDeviceCateDataVO; | 
|---|
|  |  |  | import com.doumee.dao.business.vo.YwDeviceStatusDataVO; | 
|---|
|  |  |  | import com.doumee.service.business.YwDeviceService; | 
|---|
|  |  |  | import io.swagger.annotations.Api; | 
|---|
|  |  |  | import io.swagger.annotations.ApiOperation; | 
|---|
|  |  |  | 
|---|
|  |  |  | import javax.servlet.http.HttpServletResponse; | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Set; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @author 江蹄蹄 | 
|---|
|  |  |  | 
|---|
|  |  |  | @PostMapping("/create") | 
|---|
|  |  |  | @CloudRequiredPermission("business:ywdevice:create") | 
|---|
|  |  |  | public ApiResponse create(@RequestBody YwDevice ywDevice,@RequestHeader(Constants.HEADER_USER_TOKEN) String token) { | 
|---|
|  |  |  | ywDevice.setLoginUserInfo(this.getLoginUser(token)); | 
|---|
|  |  |  | return ApiResponse.success(ywDeviceService.create(ywDevice)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | @GetMapping("/delete/{id}") | 
|---|
|  |  |  | @CloudRequiredPermission("business:ywdevice:delete") | 
|---|
|  |  |  | public ApiResponse deleteById(@PathVariable Integer id,@RequestHeader(Constants.HEADER_USER_TOKEN) String token) { | 
|---|
|  |  |  | ywDeviceService.deleteById(id); | 
|---|
|  |  |  | ywDeviceService.deleteById(id,this.getLoginUser(token)); | 
|---|
|  |  |  | return ApiResponse.success(null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | for (String id : idArray) { | 
|---|
|  |  |  | idList.add(Integer.valueOf(id)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ywDeviceService.deleteByIdInBatch(idList); | 
|---|
|  |  |  | ywDeviceService.deleteByIdInBatch(idList,this.getLoginUser(token)); | 
|---|
|  |  |  | return ApiResponse.success(null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | @PostMapping("/updateById") | 
|---|
|  |  |  | @CloudRequiredPermission("business:ywdevice:update") | 
|---|
|  |  |  | public ApiResponse updateById(@RequestBody YwDevice ywDevice,@RequestHeader(Constants.HEADER_USER_TOKEN) String token) { | 
|---|
|  |  |  | ywDevice.setLoginUserInfo(this.getLoginUser(token)); | 
|---|
|  |  |  | ywDeviceService.updateById(ywDevice); | 
|---|
|  |  |  | return ApiResponse.success(null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | @PostMapping("/page") | 
|---|
|  |  |  | @CloudRequiredPermission("business:ywdevice:query") | 
|---|
|  |  |  | public ApiResponse<PageData<YwDevice>> findPage (@RequestBody PageWrap<YwDevice> pageWrap,@RequestHeader(Constants.HEADER_USER_TOKEN) String token) { | 
|---|
|  |  |  | pageWrap.getModel().setLoginUserInfo(this.getLoginUser(token)); | 
|---|
|  |  |  | return ApiResponse.success(ywDeviceService.findPage(pageWrap)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | @PostMapping("/exportExcel") | 
|---|
|  |  |  | @CloudRequiredPermission("business:ywdevice:exportExcel") | 
|---|
|  |  |  | public void exportExcel (@RequestBody PageWrap<YwDevice> pageWrap, HttpServletResponse response,@RequestHeader(Constants.HEADER_USER_TOKEN) String token) { | 
|---|
|  |  |  | pageWrap.getModel().setLoginUserInfo(this.getLoginUser(token)); | 
|---|
|  |  |  | ExcelExporter.build(YwDevice.class).export(ywDeviceService.findPage(pageWrap).getRecords(), "运维设备信息表", response); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | @GetMapping("/{id}") | 
|---|
|  |  |  | @CloudRequiredPermission("business:ywdevice:query") | 
|---|
|  |  |  | public ApiResponse findById(@PathVariable Integer id,@RequestHeader(Constants.HEADER_USER_TOKEN) String token) { | 
|---|
|  |  |  | return ApiResponse.success(ywDeviceService.findById(id)); | 
|---|
|  |  |  | return ApiResponse.success(ywDeviceService.getDetail(id)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("根据编码查询设备") | 
|---|
|  |  |  | @GetMapping("/findByCode") | 
|---|
|  |  |  | @CloudRequiredPermission("business:ywdevice:query") | 
|---|
|  |  |  | public ApiResponse findByCode(@RequestParam String deviceCode,@RequestHeader(Constants.HEADER_USER_TOKEN) String token) { | 
|---|
|  |  |  | return ApiResponse.success(ywDeviceService.findByCode(deviceCode)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("设备数量分类统计") | 
|---|
|  |  |  | @PostMapping("/getDeviceCateData") | 
|---|
|  |  |  | @CloudRequiredPermission("business:ywdevice:query") | 
|---|
|  |  |  | public ApiResponse<Set<YwDeviceCateDataVO>> getDeviceCateData (@RequestBody YwDevice ywDevice,@RequestHeader(Constants.HEADER_USER_TOKEN) String token) { | 
|---|
|  |  |  | return ApiResponse.success(ywDeviceService.getDeviceCateData(ywDevice)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("设备状态统计") | 
|---|
|  |  |  | @PostMapping("/getDeviceStatus") | 
|---|
|  |  |  | @CloudRequiredPermission("business:ywdevice:query") | 
|---|
|  |  |  | public ApiResponse<YwDeviceStatusDataVO> getDeviceStatus (@RequestBody YwDevice ywDevice,@RequestHeader(Constants.HEADER_USER_TOKEN) String token) { | 
|---|
|  |  |  | return ApiResponse.success(ywDeviceService.getDeviceStatus(ywDevice)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|