|
|
@@ -2,13 +2,16 @@ package com.taauav.front.controller; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.taauav.admin.entity.TauvDriver; |
|
|
|
import com.taauav.admin.entity.TauvInspectQuestion; |
|
|
|
import com.taauav.admin.mapper.TauvDriverMapper; |
|
|
|
import com.taauav.common.bean.Response; |
|
|
|
import com.taauav.common.util.StringUtils; |
|
|
|
import com.taauav.front.mapper.UserInspectQuestionMapper; |
|
|
|
import com.taauav.front.mapper.UserWaterAlarmInfoMapper; |
|
|
|
import com.taauav.front.mapper.UserWaterAlarmMapper; |
|
|
|
import com.taauav.front.query.UserDriverWaterAlarmQuery; |
|
|
|
import com.taauav.front.query.UserMultiDriverWaterAlarmQuery; |
|
|
|
import com.taauav.front.vo.inspectquestion.InspectQuestionCategoryVo; |
|
|
|
import io.netty.util.internal.StringUtil; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
@@ -30,6 +33,8 @@ public class UserDataStatisticsController { |
|
|
|
@Autowired |
|
|
|
private UserWaterAlarmMapper userWaterAlarmMapper; |
|
|
|
@Autowired |
|
|
|
private TauvDriverMapper driverMapper; |
|
|
|
@Autowired |
|
|
|
private Response response; |
|
|
|
|
|
|
|
@GetMapping("/index") |
|
|
@@ -289,15 +294,15 @@ public class UserDataStatisticsController { |
|
|
|
public Response getDriverWaterAlarmInfoList(@RequestBody UserDriverWaterAlarmQuery query) { |
|
|
|
// 时间处理 |
|
|
|
if (StringUtils.isEmpty(query.getTime())) { |
|
|
|
return response.failure(""); |
|
|
|
return response.failure("请选择时间段"); |
|
|
|
} |
|
|
|
String[] time = query.getTime().split(" ~ "); |
|
|
|
|
|
|
|
String[] item = time[1].split("-"); |
|
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
Calendar date = Calendar.getInstance(); |
|
|
|
Integer year = Integer.valueOf(date.get(Calendar.YEAR)); |
|
|
|
Integer month = Integer.valueOf(date.get(Calendar.MONTH)) + 1; |
|
|
|
Integer year = Integer.valueOf(item[0]); |
|
|
|
Integer month = Integer.valueOf(item[1]); |
|
|
|
Date beginTime = getBeginTime(year, month); |
|
|
|
Date endTime = getEndTime(year, month); |
|
|
|
|
|
|
@@ -310,7 +315,7 @@ public class UserDataStatisticsController { |
|
|
|
stringList.add("TP"); |
|
|
|
|
|
|
|
List<Map<String, Object>> mapList = new ArrayList<>(); |
|
|
|
for (int i = 0; i < 5; i++) { |
|
|
|
for (int i = month - 1; i >= month - 5; i--) { |
|
|
|
String startTimeStr = addMonthDate(sdf.format(beginTime), -i, "yyyy-MM-dd HH:mm:ss"); |
|
|
|
String endTimeStr = addMonthDate(sdf.format(endTime), -i, "yyyy-MM-dd HH:mm:ss"); |
|
|
|
System.out.println(startTimeStr); |
|
|
@@ -319,13 +324,17 @@ public class UserDataStatisticsController { |
|
|
|
for (String s : stringList) { |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
map.put("driverId", query.getDriverId()); |
|
|
|
map.put("startTime", sdf.format(beginTime)); |
|
|
|
map.put("endTime", sdf.format(endTime)); |
|
|
|
map.put("startTime", startTimeStr); |
|
|
|
map.put("endTime", endTimeStr); |
|
|
|
map.put("name", s); |
|
|
|
Map<String, Object> alarmInfo = userWaterAlarmMapper.getDriverWaterAlarmInfo(map); |
|
|
|
|
|
|
|
// 获取日期 |
|
|
|
String[] timeArr = startTimeStr.split(" "); |
|
|
|
String[] dateArr = timeArr[0].split("-"); |
|
|
|
|
|
|
|
Map<String, Object> map1 = new HashMap<>(); |
|
|
|
map1.put("month", String.format("%s.%s", i, query.getMonth())); |
|
|
|
map1.put("month", Integer.valueOf(dateArr[1])); |
|
|
|
map1.put("name", s); |
|
|
|
if (alarmInfo != null) { |
|
|
|
map1.put("value", alarmInfo.get("value")); |
|
|
@@ -335,7 +344,121 @@ public class UserDataStatisticsController { |
|
|
|
mapList.add(map1); |
|
|
|
} |
|
|
|
} |
|
|
|
return response.success(mapList); |
|
|
|
} |
|
|
|
|
|
|
|
return null; |
|
|
|
/** |
|
|
|
* 获取单河流水质分析信息 |
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@PostMapping("/getMultiDriverWaterAlarmInfo") |
|
|
|
public Response getMultiDriverWaterAlarmInfo(@RequestBody UserMultiDriverWaterAlarmQuery query) { |
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
Calendar date = Calendar.getInstance(); |
|
|
|
// 获取当前年份 |
|
|
|
Integer year = Integer.valueOf(date.get(Calendar.YEAR)); |
|
|
|
// 河流ID |
|
|
|
String[] strings = query.getDriverId().split(","); |
|
|
|
List<Map<String, Object>> mapList = new ArrayList<>(); |
|
|
|
for (int i = year - 4; i <= year; i++) { |
|
|
|
// 开始时间 |
|
|
|
Date beginTime = getBeginTime(i, query.getMonth()); |
|
|
|
// 结束时间 |
|
|
|
Date endTime = getEndTime(i, query.getMonth()); |
|
|
|
System.out.println("开始时间:" + sdf.format(beginTime)); |
|
|
|
System.out.println("结束时间:" + sdf.format(endTime)); |
|
|
|
|
|
|
|
for (String string : strings) { |
|
|
|
// 河湖ID |
|
|
|
Integer driverId = Integer.valueOf(string); |
|
|
|
// 获取河湖信息 |
|
|
|
TauvDriver driver = driverMapper.selectById(driverId); |
|
|
|
if (driver == null) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
map.put("driverId", driverId); |
|
|
|
map.put("startTime", sdf.format(beginTime)); |
|
|
|
map.put("endTime", sdf.format(endTime)); |
|
|
|
map.put("name", query.getName()); |
|
|
|
Map<String, Object> alarmInfo = userWaterAlarmMapper.getMultiDriverWaterAlarmInfo(map); |
|
|
|
Map<String, Object> map1 = new HashMap<>(); |
|
|
|
map1.put("month", String.format("%s.%s", i, query.getMonth())); |
|
|
|
map1.put("name", driver.getName()); |
|
|
|
if (alarmInfo != null) { |
|
|
|
map1.put("value", alarmInfo.get("value")); |
|
|
|
} else { |
|
|
|
map1.put("value", 0); |
|
|
|
} |
|
|
|
mapList.add(map1); |
|
|
|
} |
|
|
|
} |
|
|
|
return response.success(mapList); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 单河流环比分析 |
|
|
|
* |
|
|
|
* @param query 参数 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@PostMapping("/getMultiDriverWaterAlarmInfoList") |
|
|
|
public Response getMultiDriverWaterAlarmInfoList(@RequestBody UserMultiDriverWaterAlarmQuery query) { |
|
|
|
// 时间处理 |
|
|
|
if (StringUtils.isEmpty(query.getTime())) { |
|
|
|
return response.failure("请选择时间段"); |
|
|
|
} |
|
|
|
String[] time = query.getTime().split(" ~ "); |
|
|
|
String[] item = time[1].split("-"); |
|
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
Calendar date = Calendar.getInstance(); |
|
|
|
Integer year = Integer.valueOf(item[0]); |
|
|
|
Integer month = Integer.valueOf(item[1]); |
|
|
|
Date beginTime = getBeginTime(year, month); |
|
|
|
Date endTime = getEndTime(year, month); |
|
|
|
|
|
|
|
// 河流ID |
|
|
|
String[] strings = query.getDriverId().split(","); |
|
|
|
|
|
|
|
List<Map<String, Object>> mapList = new ArrayList<>(); |
|
|
|
for (int i = month - 1; i >= month - 5; i--) { |
|
|
|
String startTimeStr = addMonthDate(sdf.format(beginTime), -i, "yyyy-MM-dd HH:mm:ss"); |
|
|
|
String endTimeStr = addMonthDate(sdf.format(endTime), -i, "yyyy-MM-dd HH:mm:ss"); |
|
|
|
System.out.println(startTimeStr); |
|
|
|
System.out.println(endTimeStr); |
|
|
|
|
|
|
|
for (String string : strings) { |
|
|
|
// 河湖ID |
|
|
|
Integer driverId = Integer.valueOf(string); |
|
|
|
// 获取河湖信息 |
|
|
|
TauvDriver driver = driverMapper.selectById(driverId); |
|
|
|
if (driver == null) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
map.put("driverId", driverId); |
|
|
|
map.put("startTime", startTimeStr); |
|
|
|
map.put("endTime", endTimeStr); |
|
|
|
map.put("name", query.getName()); |
|
|
|
Map<String, Object> alarmInfo = userWaterAlarmMapper.getMultiDriverWaterAlarmInfo(map); |
|
|
|
|
|
|
|
// 获取日期 |
|
|
|
String[] timeArr = startTimeStr.split(" "); |
|
|
|
String[] dateArr = timeArr[0].split("-"); |
|
|
|
|
|
|
|
Map<String, Object> map1 = new HashMap<>(); |
|
|
|
map1.put("month", Integer.valueOf(dateArr[1])); |
|
|
|
map1.put("name", driver.getName()); |
|
|
|
if (alarmInfo != null) { |
|
|
|
map1.put("value", alarmInfo.get("value")); |
|
|
|
} else { |
|
|
|
map1.put("value", 0); |
|
|
|
} |
|
|
|
mapList.add(map1); |
|
|
|
} |
|
|
|
} |
|
|
|
return response.success(mapList); |
|
|
|
} |
|
|
|
} |