| | |
| | | package com.yuanchu.mom.controller; |
| | | |
| | | |
| | | import cn.hutool.core.lang.UUID; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.mom.annotation.ValueAuth; |
| | | import com.yuanchu.mom.dto.DeviceDto; |
| | | import com.yuanchu.mom.pojo.Device; |
| | | import com.yuanchu.mom.service.DeviceService; |
| | | import com.yuanchu.mom.utils.JackSonUtil; |
| | | import com.yuanchu.mom.vo.Result; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.File; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 设备(DeviceController)表控制层 |
| | | */ |
| | | @Api(tags = "设备") |
| | | @AllArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/deviceScope") |
| | | public class DeviceController { |
| | | |
| | | |
| | | @Resource |
| | | private DeviceService deviceService; |
| | | |
| | | @Value("${file.path}") |
| | | private String filePath; |
| | | |
| | | @ApiOperation(value = "查询设备详情列表") |
| | | @PostMapping("/selectDeviceParameter") |
| | | public Result selectDeviceParameter(@RequestBody Map<String, Object> data) throws Exception { |
| | | Page page = JackSonUtil.unmarshal(JackSonUtil.marshal(data.get("page")), Page.class); |
| | | Device itemParameter = JackSonUtil.unmarshal(JackSonUtil.marshal(data.get("entity")), Device.class); |
| | | DeviceDto itemParameter = JackSonUtil.unmarshal(JackSonUtil.marshal(data.get("entity")), DeviceDto.class); |
| | | return Result.success(deviceService.selectDeviceParameter(page, itemParameter)); |
| | | } |
| | | |
| | |
| | | return Result.success(deviceService.selectEquipmentOverview()); |
| | | } |
| | | |
| | | @ApiOperation(value = "获取被授权人") |
| | | @GetMapping("/authorizedPerson") |
| | | @ValueAuth |
| | | public Result authorizedPerson() { |
| | | return Result.success(deviceService.authorizedPerson()); |
| | | } |
| | | |
| | | @ApiOperation(value = "搜索") |
| | | @GetMapping("/search") |
| | | @ValueAuth |
| | | public Result search(Integer status, String deviceName, String specificationModel, String largeCategory) { |
| | | return Result.success(deviceService.search(status, deviceName, specificationModel, largeCategory)); |
| | | } |
| | | |
| | | //图片上传 |
| | | @ApiOperation(value = "设备图片上传") |
| | | @PostMapping("/uploadFile") |
| | | public Result uploadFile(MultipartFile file) { |
| | | String urlString; |
| | | String pathName; |
| | | String filename = file.getOriginalFilename(); |
| | | try { |
| | | String path = filePath; |
| | | File realpath = new File(path); |
| | | if (!realpath.exists()) { |
| | | realpath.mkdirs(); |
| | | } |
| | | pathName = UUID.randomUUID() + "_" + file.getOriginalFilename(); |
| | | urlString = realpath + "/" + pathName; |
| | | file.transferTo(new File(urlString)); |
| | | HashMap<String, String> map = new HashMap<>(); |
| | | map.put("name", filename); |
| | | map.put("url", pathName); |
| | | return Result.success(map); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | System.err.println("图片上传错误"); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "获取设备负责人") |
| | | @GetMapping("/selectDevicePrincipal") |
| | | @ValueAuth |
| | | public Result selectDevicePrincipal() { |
| | | return Result.success(deviceService.selectDevicePrincipal()); |
| | | } |
| | | |
| | | @ApiOperation(value = "通过项目获取设备列表") |
| | | @PostMapping("/selectDeviceByCategory") |
| | | @ValueAuth |
| | | public Result selectDeviceByCategory(String inspectionItem, String inspectionItemSubclass) { |
| | | return Result.success(deviceService.selectDeviceByCategory(inspectionItem, inspectionItemSubclass)); |
| | | } |
| | | |
| | | @ApiOperation(value = "通过设备编号获取设备列表") |
| | | @PostMapping("/selectDeviceByCode") |
| | | @ValueAuth |
| | | public Result selectDeviceByCode(String code) { |
| | | return Result.success(deviceService.selectDeviceByCode(code)); |
| | | } |
| | | } |
| | | |