package org.springblade.modules.external.ycbigdata.alarm.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.tool.api.R;
import org.springblade.homecare.alarmlist.entity.Alarm;
import org.springblade.homecare.alarmlist.service.IAlarmService;
import org.springblade.jobs.devicejob.entity.DeviceJob;
import org.springblade.jobs.devicejob.service.IDeviceJobService;
import org.springblade.jobs.reportjob.entity.ReportJob;
import org.springblade.jobs.reportjob.service.IReportJobService;
import org.springblade.modules.external.ycbigdata.alarm.vo.AlarmVO;
import org.springblade.modules.external.ycbigdata.alarm.wrapper.AlarmWrapper;
import org.springblade.modules.external.ycbigdata.job.vo.DeviceJobVO;
import org.springblade.modules.external.ycbigdata.job.vo.ReportJobVO;
import org.springblade.modules.external.ycbigdata.job.wrapper.DeviceJobWrapper;
import org.springblade.modules.external.ycbigdata.job.wrapper.ReportJobWrapper;
import org.springblade.system.orgposition.service.IOrgPositionService;
import org.springblade.utils.QueryWrapperUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * Created By lidexi in 2021/3/16
 **/
@RestController
@AllArgsConstructor
@RequestMapping("/bigdata/alarm")
@Api(value = "告警管理-对外（银川大数据）接口", tags = "告警管理-对外（银川大数据）接口")
public class AlarmExternalController {

	private IOrgPositionService orgPositionService;
	private IAlarmService alarmService;

	/**
	 * 获取告警列表
	 */
	@GetMapping("/get")
	@ApiOperationSupport(order = 2)
	@ApiOperation(value = "获取告警列表", notes = "获取告警列表")
	public R<IPage<AlarmVO>> alarmList(Alarm alarm, Query query, BladeUser bladeUser) {
		LambdaQueryWrapper<Alarm> alarmLambdaQueryWrapper = new QueryWrapperUtil<Alarm>().getBasicQueryWrapper(Alarm::getOrgPosition, alarm, bladeUser, orgPositionService);
		IPage<Alarm> page = alarmService.page(Condition.getPage(query), alarmLambdaQueryWrapper.eq(Alarm::getTenantId, bladeUser.getTenantId()));
		return R.data(AlarmWrapper.build().pageVO(page));
	}




}
