Browse Source

更新统计

master
牧羊人 4 years ago
parent
commit
6e2b1535b2
7 changed files with 199 additions and 9 deletions
  1. +5
    -0
      src/main/java/com/taauav/admin/vo/inspectdriver/TauvInspectDriverInfoVo.java
  2. +132
    -9
      src/main/java/com/taauav/front/controller/UserDataStatisticsController.java
  3. +8
    -0
      src/main/java/com/taauav/front/mapper/UserWaterAlarmMapper.java
  4. +9
    -0
      src/main/java/com/taauav/front/mapper/UserWaterAlarmMapper.xml
  5. +31
    -0
      src/main/java/com/taauav/front/query/UserMultiDriverWaterAlarmQuery.java
  6. +9
    -0
      src/main/java/com/taauav/front/service/impl/UserInspectQuestionServiceImpl.java
  7. +5
    -0
      src/main/java/com/taauav/front/vo/inspectquestion/UserInspectQuestionInfoVo.java

+ 5
- 0
src/main/java/com/taauav/admin/vo/inspectdriver/TauvInspectDriverInfoVo.java View File

*/ */
private String inspectHandName; private String inspectHandName;


/**
* 状态
*/
private Integer status;

/** /**
* 无人机设备 * 无人机设备
*/ */

+ 132
- 9
src/main/java/com/taauav/front/controller/UserDataStatisticsController.java View File



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);
} }
} }

+ 8
- 0
src/main/java/com/taauav/front/mapper/UserWaterAlarmMapper.java View File

*/ */
Map<String, Object> getDriverWaterAlarmInfo(@Param("param") Map<String, Object> param); Map<String, Object> getDriverWaterAlarmInfo(@Param("param") Map<String, Object> param);


/**
* 多条河流水质分析
*
* @param param 参数
* @return
*/
Map<String, Object> getMultiDriverWaterAlarmInfo(@Param("param") Map<String, Object> param);

} }

+ 9
- 0
src/main/java/com/taauav/front/mapper/UserWaterAlarmMapper.xml View File

GROUP BY i.`name` GROUP BY i.`name`
</select> </select>


<!-- 多河流水质数据统计 -->
<select id="getMultiDriverWaterAlarmInfo" parameterType="java.util.Map" resultType="java.util.Map">
SELECT d.`name`, count(i.`name`) AS `value` FROM tauv_water_alarm_info AS i
INNER JOIN tauv_water_alarm AS a ON a.id=i.water_alarm_id
INNER JOIN tauv_driver AS d ON d.id=a.driver_id
WHERE i.mark=1 AND a.mark=1 AND i.`name`=concat('',#{param.name},'') AND a.driver_id=#{param.driverId} AND a.create_time BETWEEN #{param.startTime} and #{param.endTime}
GROUP BY i.`name`
</select>

</mapper> </mapper>

+ 31
- 0
src/main/java/com/taauav/front/query/UserMultiDriverWaterAlarmQuery.java View File

package com.taauav.front.query;

import lombok.Data;

/**
* 单河流水质查询条件
*/
@Data
public class UserMultiDriverWaterAlarmQuery {

/**
* 河湖ID
*/
private String driverId;

/**
* 警告分类
*/
private String name;

/**
* 月份
*/
private Integer month;

/**
* 时间
*/
private String time;

}

+ 9
- 0
src/main/java/com/taauav/front/service/impl/UserInspectQuestionServiceImpl.java View File

if (!StringUtils.isEmpty(inspectQuestionInfoVo.getFileSrc())) { if (!StringUtils.isEmpty(inspectQuestionInfoVo.getFileSrc())) {
inspectQuestionInfoVo.setFileSrc(uploadUrl + inspectQuestionInfoVo.getFileSrc()); inspectQuestionInfoVo.setFileSrc(uploadUrl + inspectQuestionInfoVo.getFileSrc());
} }
// 原图
if (!StringUtils.isEmpty(inspectQuestionInfoVo.getOriginalImg())) {
inspectQuestionInfoVo.setOriginalImg(uploadUrl + inspectQuestionInfoVo.getOriginalImg());
}
// 处理之后的图片
if (!StringUtils.isEmpty(entity.getHandlerImage())) {
inspectQuestionInfoVo.setHandlerImage(uploadUrl + entity.getHandlerImage());
}
return response.success(inspectQuestionInfoVo); return response.success(inspectQuestionInfoVo);
} }




/** /**
* 获取指挥大屏问题详情 * 获取指挥大屏问题详情
*
* @param id * @param id
* @return * @return
*/ */

+ 5
- 0
src/main/java/com/taauav/front/vo/inspectquestion/UserInspectQuestionInfoVo.java View File

*/ */
private String fileSrc; private String fileSrc;


/**
* 问题原图
*/
private String originalImg;

/** /**
* 问题描述内容 * 问题描述内容
*/ */

Loading…
Cancel
Save