|
|
@@ -0,0 +1,200 @@ |
|
|
|
package com.taauav.front.controller; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.taauav.admin.entity.TauvInspectDriver; |
|
|
|
import com.taauav.admin.entity.TauvWaterAlarm; |
|
|
|
import com.taauav.admin.entity.TauvWaterWarn; |
|
|
|
import com.taauav.admin.mapper.TauvInspectDriverMapper; |
|
|
|
import com.taauav.admin.mapper.TauvWaterAlarmMapper; |
|
|
|
import com.taauav.admin.mapper.TauvWaterWarnMapper; |
|
|
|
import com.taauav.common.bean.Response; |
|
|
|
import com.taauav.front.entity.UserInspectQuestion; |
|
|
|
import com.taauav.front.entity.UserNotice; |
|
|
|
import com.taauav.front.mapper.UserInspectQuestionMapper; |
|
|
|
import com.taauav.front.mapper.UserNoticeMapper; |
|
|
|
import com.taauav.front.mapper.UserWaterAlarmInfoMapper; |
|
|
|
import com.taauav.front.vo.inspectquestion.InspectQuestionCategoryVo; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.web.bind.annotation.GetMapping; |
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
/** |
|
|
|
* 客户端首页 |
|
|
|
*/ |
|
|
|
@RestController |
|
|
|
@RequestMapping("/front/index") |
|
|
|
public class UserIndexController { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private Response response; |
|
|
|
@Autowired |
|
|
|
private TauvInspectDriverMapper inspectDriverMapper; |
|
|
|
@Autowired |
|
|
|
private UserInspectQuestionMapper inspectQuestionMapper; |
|
|
|
@Autowired |
|
|
|
private TauvWaterAlarmMapper waterAlarmMapper; |
|
|
|
@Autowired |
|
|
|
private TauvWaterWarnMapper waterWarnMapper; |
|
|
|
@Autowired |
|
|
|
private UserWaterAlarmInfoMapper userWaterAlarmInfoMapper; |
|
|
|
@Autowired |
|
|
|
private UserNoticeMapper userNoticeMapper; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 获取首页统计 |
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@GetMapping("/index") |
|
|
|
public Response index() { |
|
|
|
// 任务统计 |
|
|
|
Map<String, Object> taskInfo = getInspectTaskInfo(); |
|
|
|
// 问题统计 |
|
|
|
Map<String, Object> questionInfo = getInspectQuestionInfo(); |
|
|
|
// 获取最新4条报警信息 |
|
|
|
List<TauvWaterAlarm> waterAlarmList = getWaterAlarmList(); |
|
|
|
// 获取最新4条预警数据 |
|
|
|
List<TauvWaterWarn> waterWarnList = getWaterWarnList(); |
|
|
|
// 获取问题类型统计列表 |
|
|
|
List<InspectQuestionCategoryVo> inspectQuestionCategoryVoList = inspectQuestionMapper.getInspectQuestionCategoryList(); |
|
|
|
// 获取水质警告分类统计列表 |
|
|
|
List<Map<String, Object>> waterAlarmCategoryList = userWaterAlarmInfoMapper.getWaterAlarmCategoryList(); |
|
|
|
|
|
|
|
// 返回结果 |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
result.put("taskInfo", taskInfo); |
|
|
|
result.put("questionInfo", questionInfo); |
|
|
|
result.put("waterAlarmList", waterAlarmList); |
|
|
|
result.put("waterWarnList", waterWarnList); |
|
|
|
result.put("inspectQuestionCategoryList", inspectQuestionCategoryVoList); |
|
|
|
result.put("waterAlarmCategoryList", waterAlarmCategoryList); |
|
|
|
return response.success(result); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取任务统计信息 |
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private Map<String, Object> getInspectTaskInfo() { |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
// 获取任务总数 |
|
|
|
Integer totalNum = inspectDriverMapper.selectCount(new LambdaQueryWrapper<TauvInspectDriver>() |
|
|
|
.eq(TauvInspectDriver::getMark, 1)); |
|
|
|
map.put("totalNum", totalNum); |
|
|
|
// 获取已完成总数 |
|
|
|
Integer funishedNum = inspectDriverMapper.selectCount(new LambdaQueryWrapper<TauvInspectDriver>() |
|
|
|
.eq(TauvInspectDriver::getStatus, 4) |
|
|
|
.eq(TauvInspectDriver::getMark, 1)); |
|
|
|
map.put("funishedNum", funishedNum); |
|
|
|
// 获取执行中总数 |
|
|
|
Integer[] status = {3, 5, 6}; |
|
|
|
Integer executionNum = inspectDriverMapper.selectCount(new LambdaQueryWrapper<TauvInspectDriver>() |
|
|
|
.in(TauvInspectDriver::getStatus, status) |
|
|
|
.eq(TauvInspectDriver::getMark, 1)); |
|
|
|
map.put("executionNum", executionNum); |
|
|
|
// 获取待执行总数 |
|
|
|
Integer executionWaitNum = inspectDriverMapper.selectCount(new LambdaQueryWrapper<TauvInspectDriver>() |
|
|
|
.eq(TauvInspectDriver::getStatus, 2) |
|
|
|
.eq(TauvInspectDriver::getMark, 1)); |
|
|
|
map.put("executionWaitNum", executionWaitNum); |
|
|
|
return map; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取巡检问题信息 |
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private Map<String, Object> getInspectQuestionInfo() { |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
// 获取问题总数 |
|
|
|
Integer totalNum = inspectQuestionMapper.selectCount(new LambdaQueryWrapper<UserInspectQuestion>() |
|
|
|
.eq(UserInspectQuestion::getMark, 1)); |
|
|
|
map.put("totalNum", totalNum); |
|
|
|
// 获取已完成总数 |
|
|
|
Integer funishedNum = inspectQuestionMapper.selectCount(new LambdaQueryWrapper<UserInspectQuestion>() |
|
|
|
.eq(UserInspectQuestion::getStatus, 3) |
|
|
|
.eq(UserInspectQuestion::getMark, 1)); |
|
|
|
map.put("funishedNum", funishedNum); |
|
|
|
// 获取处理中总数 |
|
|
|
Integer processNum = inspectQuestionMapper.selectCount(new LambdaQueryWrapper<UserInspectQuestion>() |
|
|
|
.eq(UserInspectQuestion::getStatus, 2) |
|
|
|
.eq(UserInspectQuestion::getMark, 1)); |
|
|
|
map.put("processNum", processNum); |
|
|
|
// 获取待处理总数 |
|
|
|
Integer waitNum = inspectQuestionMapper.selectCount(new LambdaQueryWrapper<UserInspectQuestion>() |
|
|
|
.eq(UserInspectQuestion::getStatus, 1) |
|
|
|
.eq(UserInspectQuestion::getMark, 1)); |
|
|
|
map.put("waitNum", waitNum); |
|
|
|
return map; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取一定条数的报警数据 |
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private List<TauvWaterAlarm> getWaterAlarmList() { |
|
|
|
QueryWrapper<TauvWaterAlarm> queryWrapper = new QueryWrapper<>(); |
|
|
|
queryWrapper.eq("mark", 1); |
|
|
|
queryWrapper.gt("status", 1); |
|
|
|
queryWrapper.orderByDesc("id"); |
|
|
|
IPage<TauvWaterAlarm> page = new Page<>(1, 4); |
|
|
|
IPage<TauvWaterAlarm> data = waterAlarmMapper.selectPage(page, queryWrapper); |
|
|
|
List<TauvWaterAlarm> waterAlarmList = data.getRecords(); |
|
|
|
waterAlarmList.forEach(item -> { |
|
|
|
item.setStatusText(item.statusList().get(item.getStatus().toString())); |
|
|
|
}); |
|
|
|
return waterAlarmList; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取一定条数的预警数据 |
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private List<TauvWaterWarn> getWaterWarnList() { |
|
|
|
QueryWrapper<TauvWaterWarn> queryWrapper = new QueryWrapper<>(); |
|
|
|
queryWrapper.eq("mark", 1); |
|
|
|
queryWrapper.gt("status", 1); |
|
|
|
queryWrapper.orderByDesc("id"); |
|
|
|
IPage<TauvWaterWarn> page = new Page<>(1, 4); |
|
|
|
IPage<TauvWaterWarn> data = waterWarnMapper.selectPage(page, queryWrapper); |
|
|
|
List<TauvWaterWarn> waterWarnList = data.getRecords(); |
|
|
|
if (!waterWarnList.isEmpty()) { |
|
|
|
waterWarnList.forEach(item -> { |
|
|
|
item.setStatusText(item.statusList().get(item.getStatus().toString())); |
|
|
|
}); |
|
|
|
} |
|
|
|
return waterWarnList; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据类型获取通知公告信息 |
|
|
|
* |
|
|
|
* @param type 公告类型:1水务新闻 2政策法规 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@GetMapping("/getNoticeList") |
|
|
|
private Response getNoticeList(Integer type) { |
|
|
|
QueryWrapper<UserNotice> queryWrapper = new QueryWrapper<>(); |
|
|
|
queryWrapper.eq("mark", 1); |
|
|
|
queryWrapper.gt("status", 1); |
|
|
|
queryWrapper.orderByDesc("id"); |
|
|
|
IPage<UserNotice> page = new Page<>(1, 4); |
|
|
|
IPage<UserNotice> data = userNoticeMapper.selectPage(page, queryWrapper); |
|
|
|
return response.success(data.getRecords()); |
|
|
|
} |
|
|
|
|
|
|
|
} |