|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
|
import com.taauav.admin.entity.TauvDriver; |
|
|
import com.taauav.admin.entity.TauvInspectQuestion; |
|
|
import com.taauav.admin.entity.TauvInspectQuestion; |
|
|
|
|
|
import com.taauav.admin.mapper.TauvDriverMapper; |
|
|
import com.taauav.common.bean.Response; |
|
|
import com.taauav.common.bean.Response; |
|
|
import com.taauav.common.util.StringUtils; |
|
|
import com.taauav.common.util.StringUtils; |
|
|
import com.taauav.front.mapper.UserInspectQuestionMapper; |
|
|
import com.taauav.front.mapper.UserInspectQuestionMapper; |
|
|
import com.taauav.front.mapper.UserWaterAlarmInfoMapper; |
|
|
import com.taauav.front.mapper.UserWaterAlarmInfoMapper; |
|
|
import com.taauav.front.mapper.UserWaterAlarmMapper; |
|
|
import com.taauav.front.mapper.UserWaterAlarmMapper; |
|
|
import com.taauav.front.query.UserDriverWaterAlarmQuery; |
|
|
import com.taauav.front.query.UserDriverWaterAlarmQuery; |
|
|
|
|
|
import com.taauav.front.query.UserMultiDriverWaterAlarmQuery; |
|
|
import com.taauav.front.vo.inspectquestion.InspectQuestionCategoryVo; |
|
|
import com.taauav.front.vo.inspectquestion.InspectQuestionCategoryVo; |
|
|
import io.netty.util.internal.StringUtil; |
|
|
import io.netty.util.internal.StringUtil; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
private UserWaterAlarmMapper userWaterAlarmMapper; |
|
|
private UserWaterAlarmMapper userWaterAlarmMapper; |
|
|
@Autowired |
|
|
@Autowired |
|
|
|
|
|
private TauvDriverMapper driverMapper; |
|
|
|
|
|
@Autowired |
|
|
private Response response; |
|
|
private Response response; |
|
|
|
|
|
|
|
|
@GetMapping("/index") |
|
|
@GetMapping("/index") |
|
|
|
|
|
|
|
|
public Response getDriverWaterAlarmInfoList(@RequestBody UserDriverWaterAlarmQuery query) { |
|
|
public Response getDriverWaterAlarmInfoList(@RequestBody UserDriverWaterAlarmQuery query) { |
|
|
// 时间处理 |
|
|
// 时间处理 |
|
|
if (StringUtils.isEmpty(query.getTime())) { |
|
|
if (StringUtils.isEmpty(query.getTime())) { |
|
|
return response.failure(""); |
|
|
|
|
|
|
|
|
return response.failure("请选择时间段"); |
|
|
} |
|
|
} |
|
|
String[] time = query.getTime().split(" ~ "); |
|
|
String[] time = query.getTime().split(" ~ "); |
|
|
|
|
|
|
|
|
|
|
|
String[] item = time[1].split("-"); |
|
|
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
Calendar date = Calendar.getInstance(); |
|
|
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 beginTime = getBeginTime(year, month); |
|
|
Date endTime = getEndTime(year, month); |
|
|
Date endTime = getEndTime(year, month); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stringList.add("TP"); |
|
|
stringList.add("TP"); |
|
|
|
|
|
|
|
|
List<Map<String, Object>> mapList = new ArrayList<>(); |
|
|
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 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"); |
|
|
String endTimeStr = addMonthDate(sdf.format(endTime), -i, "yyyy-MM-dd HH:mm:ss"); |
|
|
System.out.println(startTimeStr); |
|
|
System.out.println(startTimeStr); |
|
|
|
|
|
|
|
|
for (String s : stringList) { |
|
|
for (String s : stringList) { |
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
map.put("driverId", query.getDriverId()); |
|
|
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.put("name", s); |
|
|
Map<String, Object> alarmInfo = userWaterAlarmMapper.getDriverWaterAlarmInfo(map); |
|
|
Map<String, Object> alarmInfo = userWaterAlarmMapper.getDriverWaterAlarmInfo(map); |
|
|
|
|
|
|
|
|
|
|
|
// 获取日期 |
|
|
|
|
|
String[] timeArr = startTimeStr.split(" "); |
|
|
|
|
|
String[] dateArr = timeArr[0].split("-"); |
|
|
|
|
|
|
|
|
Map<String, Object> map1 = new HashMap<>(); |
|
|
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); |
|
|
map1.put("name", s); |
|
|
if (alarmInfo != null) { |
|
|
if (alarmInfo != null) { |
|
|
map1.put("value", alarmInfo.get("value")); |
|
|
map1.put("value", alarmInfo.get("value")); |
|
|
|
|
|
|
|
|
mapList.add(map1); |
|
|
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); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |