|  |  |  | 
|---|
|  |  |  | import io.swagger.annotations.ApiOperation; | 
|---|
|  |  |  | import io.swagger.annotations.ApiParam; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.springframework.beans.BeanUtils; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.util.ObjectUtils; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.GetMapping; | 
|---|
|  |  |  | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RestController; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.moral.api.entity.Device; | 
|---|
|  |  |  | import com.moral.api.entity.Organization; | 
|---|
|  |  |  | import com.moral.api.entity.MonitorPoint; | 
|---|
|  |  |  | import com.moral.api.pojo.vo.device.AppDeviceVo; | 
|---|
|  |  |  | import com.moral.api.service.DeviceService; | 
|---|
|  |  |  | import com.moral.api.service.OrganizationService; | 
|---|
|  |  |  | import com.moral.constant.ResponseCodeEnum; | 
|---|
|  |  |  | import com.moral.api.service.MonitorPointService; | 
|---|
|  |  |  | import com.moral.api.service.SpecialDeviceService; | 
|---|
|  |  |  | import com.moral.constant.ResultMessage; | 
|---|
|  |  |  | import com.sun.org.apache.regexp.internal.RE; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | @Api(tags = {"小程序设备管理"}) | 
|---|
|  |  |  | 
|---|
|  |  |  | public class AppDevicController { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private OrganizationService organizationService; | 
|---|
|  |  |  | private MonitorPointService monitorPointService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private DeviceService deviceService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SpecialDeviceService specialDeviceService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @GetMapping("selectOrganization") | 
|---|
|  |  |  | @ApiOperation(value = "小程序获取组织") | 
|---|
|  |  |  | @ApiOperation(value = "小程序获取站点") | 
|---|
|  |  |  | public ResultMessage selectOrganization(){ | 
|---|
|  |  |  | List<Organization> organizations = organizationService.getOrganizations(); | 
|---|
|  |  |  | return ResultMessage.ok(organizations); | 
|---|
|  |  |  | List<MonitorPoint> monitorPoints = monitorPointService.getOrganizations(); | 
|---|
|  |  |  | return ResultMessage.ok(monitorPoints); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @GetMapping("selectDevice") | 
|---|
|  |  |  | @ApiOperation(value = "小程序获取设备") | 
|---|
|  |  |  | public ResultMessage selectDevice(@RequestParam @ApiParam(value = "organizationId",name = "组织ID") Integer organizationId){ | 
|---|
|  |  |  | List<Device> organizationDevice = deviceService.getOrganizationDevice(organizationId); | 
|---|
|  |  |  | if (ObjectUtils.isEmpty(organizationDevice)){ | 
|---|
|  |  |  | return ResultMessage.fail(ResponseCodeEnum.TARGET_IS_NULL.getCode(), ResponseCodeEnum.TARGET_IS_NULL.getMsg()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return ResultMessage.ok(organizationDevice); | 
|---|
|  |  |  | public ResultMessage selectDevice(@RequestParam @ApiParam(value = "monitorPointId",name = "站点ID") Integer monitorPointId){ | 
|---|
|  |  |  | List<Device> organizationDevice = deviceService.getOrganizationDevice(monitorPointId); | 
|---|
|  |  |  | return ResultMessage.ok(ObjectUtils.isEmpty(organizationDevice)?null:organizationDevice); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @GetMapping("fuzzySearch") | 
|---|
|  |  |  | @ApiOperation(value = "小程序模糊搜索") | 
|---|
|  |  |  | public ResultMessage fuzzySearch(@RequestParam @ApiParam(value = "mac",name = "设备mac号") String mac){ | 
|---|
|  |  |  | List<Device> devices = deviceService.getFuzzySearch(mac); | 
|---|
|  |  |  | List<AppDeviceVo> devices = deviceService.getFuzzySearch(mac); | 
|---|
|  |  |  | return ResultMessage.ok(devices); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @GetMapping("specialDevice") | 
|---|
|  |  |  | @ApiOperation(value = "查询特殊设备") | 
|---|
|  |  |  | public ResultMessage selectSpecialDevice(){ | 
|---|
|  |  |  | List<AppDeviceVo> appDeviceVos = specialDeviceService.selectSpecialDevice(); | 
|---|
|  |  |  | return ResultMessage.ok(appDeviceVos); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|