Browse Source

大屏统计完善

master
牧羊人 4 years ago
parent
commit
05a75d91a8
13 changed files with 370 additions and 22 deletions
  1. +6
    -6
      src/main/java/com/taauav/front/controller/UserAuthGroupController.java
  2. +3
    -1
      src/main/java/com/taauav/front/controller/UserInspectDriverController.java
  3. +42
    -4
      src/main/java/com/taauav/front/controller/UserLoginController.java
  4. +20
    -0
      src/main/java/com/taauav/front/controller/UserNoticeController.java
  5. +171
    -0
      src/main/java/com/taauav/front/controller/UserScreenController.java
  6. +11
    -0
      src/main/java/com/taauav/front/controller/UserWaterAlarmController.java
  7. +20
    -4
      src/main/java/com/taauav/front/controller/UserWaterWarnController.java
  8. +26
    -0
      src/main/java/com/taauav/front/mapper/UserInspectQuestionMapper.java
  9. +28
    -1
      src/main/java/com/taauav/front/mapper/UserInspectQuestionMapper.xml
  10. +2
    -2
      src/main/java/com/taauav/front/query/UserInspectQuestionQuery.java
  11. +8
    -0
      src/main/java/com/taauav/front/service/IUserWaterAlarmService.java
  12. +8
    -4
      src/main/java/com/taauav/front/service/impl/UserInspectQuestionServiceImpl.java
  13. +25
    -0
      src/main/java/com/taauav/front/service/impl/UserWaterAlarmServiceImpl.java

+ 6
- 6
src/main/java/com/taauav/front/controller/UserAuthGroupController.java View File

@@ -38,7 +38,7 @@ public class UserAuthGroupController extends FrontBaseController {
* @return
*/
@PostMapping("/index")
@RequiresPermissions(controllerName + ":" + PermissionConstants.LIST_PERMISSION)
// @RequiresPermissions(controllerName + ":" + PermissionConstants.LIST_PERMISSION)
public Response index(@RequestBody UserAuthGroupQuery query) {
return userAuthGroupService.getList(query);
}
@@ -51,7 +51,7 @@ public class UserAuthGroupController extends FrontBaseController {
* @return
*/
@PostMapping("/add")
@RequiresPermissions(controllerName + ":" + PermissionConstants.ADD_PERMISSION)
// @RequiresPermissions(controllerName + ":" + PermissionConstants.ADD_PERMISSION)
public Response add(@RequestBody(required = true) UserAuthGroup entity, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
String message = bindingResult.getFieldError().getDefaultMessage();
@@ -67,7 +67,7 @@ public class UserAuthGroupController extends FrontBaseController {
* @return
*/
@GetMapping("/info")
@RequiresPermissions(controllerName + ":" + PermissionConstants.EDIT_PERMISSION)
// @RequiresPermissions(controllerName + ":" + PermissionConstants.EDIT_PERMISSION)
public Response info(Integer id) {
return userAuthGroupService.info(id);
}
@@ -80,7 +80,7 @@ public class UserAuthGroupController extends FrontBaseController {
* @return
*/
@PostMapping("/edit")
@RequiresPermissions(controllerName + ":" + PermissionConstants.EDIT_PERMISSION)
// @RequiresPermissions(controllerName + ":" + PermissionConstants.EDIT_PERMISSION)
public Response edit(@RequestBody(required = false) UserAuthGroup entity, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
String message = bindingResult.getFieldError().getDefaultMessage();
@@ -96,7 +96,7 @@ public class UserAuthGroupController extends FrontBaseController {
* @return
*/
@PostMapping("/drop")
@RequiresPermissions(controllerName + ":" + PermissionConstants.REMOVE_PERMISSION)
// @RequiresPermissions(controllerName + ":" + PermissionConstants.REMOVE_PERMISSION)
public Response drop(Integer id) {
return userAuthGroupService.drop(id);
}
@@ -108,7 +108,7 @@ public class UserAuthGroupController extends FrontBaseController {
* @return
*/
@PostMapping("/setStatus")
@RequiresPermissions(controllerName + ":" + PermissionConstants.STATUS_PERMISSION)
// @RequiresPermissions(controllerName + ":" + PermissionConstants.STATUS_PERMISSION)
public Response setStatus(@RequestBody(required = true) UserAuthGroup entity) {
return userAuthGroupService.setStatus(entity);
}

+ 3
- 1
src/main/java/com/taauav/front/controller/UserInspectDriverController.java View File

@@ -1,6 +1,7 @@
package com.taauav.front.controller;


import com.taauav.admin.entity.TauvInspectDriver;
import com.taauav.common.bean.Response;
import com.taauav.common.constant.PermissionConstants;
import com.taauav.front.query.UserInspectDriverQuery;
@@ -43,7 +44,8 @@ public class UserInspectDriverController extends FrontBaseController {
}
String status = "status";
if (map.containsKey(status) && !"".equals(map.get(status))) {
map.put("status", Integer.valueOf(map.get(status).toString()));
Integer[] st = new Integer[]{Integer.valueOf(map.get(status).toString())};
map.put("status", st);
} else {
map.put("status", new Integer[]{2, 3, 4, 5, 6});
}

+ 42
- 4
src/main/java/com/taauav/front/controller/UserLoginController.java View File

@@ -1,13 +1,17 @@
package com.taauav.front.controller;

import com.taauav.common.bean.Response;
import com.taauav.common.util.RedisUtils;
import com.taauav.common.util.VerifyUtil;
import com.taauav.front.dto.LoginDto;
import com.taauav.front.service.IUserLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

@RestController
@RequestMapping("/front/login")
@@ -15,6 +19,10 @@ public class UserLoginController {

@Autowired
private IUserLoginService loginService;
@Autowired
private RedisUtils redisUtils;
@Autowired
private Response response;

/**
* 系统登录
@@ -27,4 +35,34 @@ public class UserLoginController {
return loginService.login(loginDto);
}

/**
* 图片验证码
*
* @param resp
* @return
*/
@GetMapping("/captcha")
public Response captcha(HttpServletResponse resp) {
VerifyUtil verifyUtil = new VerifyUtil();
Map result = new HashMap();
try {
String key = UUID.randomUUID().toString();
resp.setContentType("image/png");
resp.setHeader("Cache-Control", "no-cache");
resp.setHeader("Expire", "0");
resp.setHeader("Pragma", "no-cache");
// 返回base64
//写入redis缓存
Map<String, String> mapInfo = verifyUtil.getRandomCodeBase64();
String randomStr = mapInfo.get("randomStr");
redisUtils.set(key, randomStr, 60 * 5);

result.put("url", "data:image/png;base64," + mapInfo.get("img"));
result.put("key", key);
} catch (Exception e) {
return response.failure(e.getMessage());
}
return response.success(result);
}

}

+ 20
- 0
src/main/java/com/taauav/front/controller/UserNoticeController.java View File

@@ -1,7 +1,10 @@
package com.taauav.front.controller;


import com.taauav.admin.entity.TauvEquipment;
import com.taauav.admin.entity.TauvInspect;
import com.taauav.common.bean.Response;
import com.taauav.front.constant.UserNoticeConstant;
import com.taauav.front.entity.UserNotice;
import com.taauav.front.query.UserNoticeQuery;
import com.taauav.front.service.IUserNoticeService;
@@ -10,6 +13,10 @@ import org.springframework.web.bind.annotation.*;

import com.taauav.front.controller.FrontBaseController;

import java.math.BigInteger;
import java.util.HashMap;
import java.util.Map;

/**
* <p>
* 通知公告表 前端控制器
@@ -24,6 +31,8 @@ public class UserNoticeController extends FrontBaseController {

@Autowired
private IUserNoticeService noticeService;
@Autowired
private Response response;

/**
* 获取通知公告列表
@@ -80,4 +89,15 @@ public class UserNoticeController extends FrontBaseController {
return noticeService.delete(noticeId);
}

/**
* 获取基础数据
*
* @return
*/
@GetMapping("/getBaseData")
public Response getBaseData() {
Map<String, Object> result = new HashMap<>();
result.put("typeList", UserNoticeConstant.USER_NOTICE_TYPE_LIST);
return response.success("操作成功", result);
}
}

+ 171
- 0
src/main/java/com/taauav/front/controller/UserScreenController.java View File

@@ -0,0 +1,171 @@
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.SysCity;
import com.taauav.admin.mapper.SysCityMapper;
import com.taauav.admin.mapper.TauvWaterAlarmInfoMapper;
import com.taauav.admin.mapper.TauvWaterAlarmMapper;
import com.taauav.admin.service.ISysCityService;
import com.taauav.common.bean.Response;
import com.taauav.front.entity.UserInspectQuestion;
import com.taauav.front.mapper.UserInspectQuestionMapper;
import com.taauav.front.mapper.UserWaterAlarmInfoMapper;
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.math.BigInteger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


@RestController
@RequestMapping("/front/screen")
public class UserScreenController {

@Autowired
private UserInspectQuestionMapper inspectQuestionMapper;
@Autowired
private ISysCityService cityService;
@Autowired
private SysCityMapper cityMapper;
@Autowired
private UserWaterAlarmInfoMapper waterAlarmInfoMapper;
@Autowired
private Response response;

/**
* 大屏统计
*
* @return
*/
@GetMapping("/index")
public Response index() {
// 巡检问题处理情况统计
Map<String, Object> inspectQuestionInfo = getInspectQuestionInfo();
// 获取待处理污染
List<Map<String, Object>> waitQuestionInfo = getCategoryQuestionInfo();
// 巡检问题河湖统计
List<Map<String, Object>> questionDriverList = inspectQuestionMapper.getQuestionDriverList();
// 获取区属问题统计
List<Map<String, Object>> questionDriverAreaList = getQuestionDriverAreaList();
// 获取河湖水质问题分类统计
List<Map<String, String>> waterAlarmCategoryList = getWaterAlarmCategoryList();

// 返回结果
Map<String, Object> result = new HashMap<>();
result.put("inspectQuestionInfo", inspectQuestionInfo);
result.put("waitQuestionInfo", waitQuestionInfo);
result.put("questionDriverList", questionDriverList);
result.put("questionDriverAreaList", questionDriverAreaList);
result.put("waterAlarmCategoryList", waterAlarmCategoryList);
return response.success(result);
}

/**
* 巡检问题处理情况统计
*
* @return
*/
private Map<String, Object> getInspectQuestionInfo() {
Map<String, Object> result = new HashMap<>();
// 获取已发现问题数
Integer totalNum = inspectQuestionMapper.selectCount(new LambdaQueryWrapper<UserInspectQuestion>()
.eq(UserInspectQuestion::getMark, 1));
result.put("totalNum", totalNum);
// 获取已解决问题数
Integer finishedNum = inspectQuestionMapper.selectCount(new LambdaQueryWrapper<UserInspectQuestion>()
.eq(UserInspectQuestion::getStatus, 3)
.eq(UserInspectQuestion::getMark, 1));
result.put("finishedNum", finishedNum);
return result;
}

/**
* 获取待处理污染问题统计
*
* @return
*/
private List<Map<String, Object>> getCategoryQuestionInfo() {
String category = "1=水面,2=岸线,3=排口,4=水质";
String[] strings = category.split(",");
List<Map<String, Object>> mapList = new ArrayList<>();
for (String string : strings) {
String[] strings1 = string.split("=");

Map<String, Object> categoryMap = inspectQuestionMapper.getCategoryQuestionInfo(Integer.valueOf(strings1[0]));
Map<String, Object> map = new HashMap<>();
map.put("name", strings1[1]);
if (categoryMap != null) {
map.put("totalNum", categoryMap.get("total_num"));
} else {
map.put("totalNum", 0);
}
mapList.add(map);
}
return mapList;
}

/**
* 获取区属问题河湖统计
*
* @return
*/
private List<Map<String, Object>> getQuestionDriverAreaList() {
List<Map<String, Object>> mapList = inspectQuestionMapper.getQuestionDriverAreaList();
List<String> stringList = new ArrayList<>();
if (!mapList.isEmpty()) {
mapList.forEach(item -> {
stringList.add(item.get("id").toString());
});
}

QueryWrapper<SysCity> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("pid", 3201);
queryWrapper.eq("mark", 1);
List<SysCity> cityList = cityMapper.selectList(queryWrapper);
if (!cityList.isEmpty()) {
cityList.forEach(item -> {
if (!stringList.contains(item.getId().toString())) {
Map<String, Object> map = new HashMap<>();
map.put("id", item.getId());
map.put("name", item.getName());
map.put("num", 0);
mapList.add(map);
}
});
}
return mapList;
}

/**
* 河湖水质问题分类统计
*
* @return
*/
private List<Map<String, String>> getWaterAlarmCategoryList() {
List<Map<String, Object>> mapList = waterAlarmInfoMapper.getWaterAlarmCategoryList();
List<Map<String, String>> result = new ArrayList<>();
Integer totalNum = 0;
if (!mapList.isEmpty()) {
for (Map<String, Object> map : mapList) {
totalNum += Integer.valueOf(map.get("totalNum").toString());
}
if (totalNum > 0) {
// 计算百分比
for (Map<String, Object> map : mapList) {
Map<String, String> item = new HashMap<>();
item.put("name", map.get("name").toString());
item.put("value", String.format("%.2f", (float) Integer.valueOf(map.get("totalNum").toString()) / (float) totalNum * 100));
result.add(item);
}
}
}
return result;
}

}

+ 11
- 0
src/main/java/com/taauav/front/controller/UserWaterAlarmController.java View File

@@ -57,4 +57,15 @@ public class UserWaterAlarmController extends FrontBaseController {
return userWaterAlarmService.cancel(ids);
}

/**
* 获取警告信息列表(大屏统计使用)
*
* @param num
* @return
*/
@GetMapping("/getWaterAlarmList")
public Response getWaterAlarmList(Integer num) {
return userWaterAlarmService.getWaterAlarmList(num);
}

}

+ 20
- 4
src/main/java/com/taauav/front/controller/UserWaterWarnController.java View File

@@ -2,14 +2,14 @@ package com.taauav.front.controller;


import com.taauav.common.bean.Response;
import com.taauav.front.constant.UserWaterWarnConstant;
import com.taauav.front.query.UserWaterWarnQuery;
import com.taauav.front.service.IUserWaterWarnService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;

/**
* <p>
@@ -25,6 +25,8 @@ public class UserWaterWarnController extends FrontBaseController {

@Autowired
private IUserWaterWarnService userWaterWarnService;
@Autowired
private Response response;

/**
* 获取水质预警列表
@@ -48,4 +50,18 @@ public class UserWaterWarnController extends FrontBaseController {
return userWaterWarnService.cancel(ids);
}

/**
* 获取基础数据
*
* @return
*/
@GetMapping("/getBaseData")
public Response getBaseData() {
Map<String, Object> result = new HashMap<>();
result.put("typeList", UserWaterWarnConstant.USER_WATER_WARN_TYPE_LIST);
result.put("levelList", UserWaterWarnConstant.USER_WATER_WARN_LEVEL_LIST);
result.put("statusList", UserWaterWarnConstant.USER_WATER_WARN_STATUS_LIST);
return response.success(result);
}

}

+ 26
- 0
src/main/java/com/taauav/front/mapper/UserInspectQuestionMapper.java View File

@@ -7,9 +7,12 @@ import com.taauav.front.query.UserInspectQuestionQuery;
import com.taauav.front.vo.inspectquestion.InspectQuestionCategoryVo;
import com.taauav.front.vo.inspectquestion.UserInspectQuestionInfoVo;
import com.taauav.front.vo.inspectquestion.UserInspectQuestionListVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.RequestParam;

import java.math.BigInteger;
import java.util.List;
import java.util.Map;

/**
* <p>
@@ -44,4 +47,27 @@ public interface UserInspectQuestionMapper extends BaseMapper<UserInspectQuestio
*/
List<InspectQuestionCategoryVo> getInspectQuestionCategoryList();

/**
* 大屏待处理污染问题统计
*
* @param category 分类ID
* @return
*/
Map<String, Object> getCategoryQuestionInfo(Integer category);

/**
* 大屏巡检问题河湖统计
*
* @return
*/
List<Map<String, Object>> getQuestionDriverList();

/**
* 大屏区属问题河湖统计
*
* @param driverArea 区划ID集合
* @return
*/
List<Map<String, Object>> getQuestionDriverAreaList();

}

+ 28
- 1
src/main/java/com/taauav/front/mapper/UserInspectQuestionMapper.xml View File

@@ -15,7 +15,7 @@
<if test="query.questionNo != null">
and q.question_no like concat('%', #{query.questionNo}, '%')
</if>
<if test="query.driverArea != null and query.driverArea !=''"> and d.driver_area in
<if test="query.driverAreaList != null and query.driverAreaList !=''"> and d.driver_area in
<foreach collection="query.driverArea" item="area" open="(" close=")" separator=",">
#{area}
</foreach>
@@ -54,4 +54,31 @@
LIMIT 0, 5;
</select>

<!-- 大屏待处理污染统计 -->
<select id="getCategoryQuestionInfo" resultType="java.util.Map">
SELECT o.category, count(f.id) AS total_num FROM tauv_inspect_file AS f
INNER JOIN tauv_question_options AS o ON o.id = f.question_id
INNER JOIN tauv_inspect_question AS q ON q.inspect_file_id = f.id
WHERE q.status &lt; 3 AND o.category=#{category} AND f.mark=1 AND f.is_effective=1 AND f.is_review=1 AND f.`status`=1 AND o.mark=1
GROUP BY o.category
</select>

<!-- 大屏巡检问题河湖统计 -->
<select id="getQuestionDriverList" resultType="java.util.Map">
SELECT d.driver_id AS driverId, d.driver_name AS driverName, count(d.driver_id) AS totalNum FROM tauv_inspect_question AS q
INNER JOIN tauv_inspect_file AS f ON q.inspect_file_id=f.id
INNER JOIN tauv_inspect_driver AS d ON d.id = f.inspect_driver_id
WHERE q.mark=1 AND f.is_review=1 AND f.is_effective=1 AND f.`status`=1 AND d.mark=1
GROUP BY d.driver_id
ORDER BY totalNum
</select>

<!-- 大屏区属问题河湖统计 -->
<select id="getQuestionDriverAreaList" resultType="java.util.Map">
SELECT c.id,c.`name`,count(d.driver_area) as num FROM tauv_inspect_question AS q
INNER JOIN tauv_inspect_driver AS d ON d.id=q.inspect_driver_id
INNER JOIN sys_city AS c ON c.id=d.driver_area
WHERE q.mark=1 AND d.mark=1
GROUP BY d.driver_area
</select>
</mapper>

+ 2
- 2
src/main/java/com/taauav/front/query/UserInspectQuestionQuery.java View File

@@ -20,12 +20,12 @@ public class UserInspectQuestionQuery extends BaseQuery {
/**
* 区划ID
*/
private BigInteger driverAreaId;
private BigInteger driverArea;

/**
* 区划ID集合
*/
private BigInteger[] driverArea;
private BigInteger[] driverAreaList;

/**
* 河湖名称

+ 8
- 0
src/main/java/com/taauav/front/service/IUserWaterAlarmService.java View File

@@ -39,4 +39,12 @@ public interface IUserWaterAlarmService extends IBaseService<TauvWaterAlarm> {
*/
Response cancel(String ids);

/**
* 获取警告信息列表
*
* @param num 获取条数
* @return
*/
Response getWaterAlarmList(Integer num);

}

+ 8
- 4
src/main/java/com/taauav/front/service/impl/UserInspectQuestionServiceImpl.java View File

@@ -62,12 +62,12 @@ public class UserInspectQuestionServiceImpl extends BaseServiceImpl<UserInspectQ
@Override
public Response getList(UserInspectQuestionQuery query) {
// 区划ID处理
if (query.getDriverAreaId() != null) {
List<BigInteger> cityIds = sysCityService.getChildCityIds(query.getDriverAreaId());
if (query.getDriverArea() != null) {
List<BigInteger> cityIds = sysCityService.getChildCityIds(query.getDriverArea());
// 加入当前选中的区划
cityIds.add(query.getDriverAreaId());
cityIds.add(query.getDriverArea());
BigInteger[] integers = cityIds.toArray(new BigInteger[cityIds.size()]);
query.setDriverArea(integers);
query.setDriverAreaList(integers);
}
// 巡检时间处理
if (!StringUtils.isEmpty(query.getInspectTime())) {
@@ -205,6 +205,10 @@ public class UserInspectQuestionServiceImpl extends BaseServiceImpl<UserInspectQ
return response.failure("巡检问题信息不存在");
}
UserInspectQuestionInfoVo inspectQuestionInfoVo = inspectQuestionMapper.getInspectQuestionInfoById(id);
// 图片处理
if (!StringUtils.isEmpty(inspectQuestionInfoVo.getFileSrc())) {
inspectQuestionInfoVo.setFileSrc(uploadUrl + inspectQuestionInfoVo.getFileSrc());
}
return response.success(inspectQuestionInfoVo);
}


+ 25
- 0
src/main/java/com/taauav/front/service/impl/UserWaterAlarmServiceImpl.java View File

@@ -165,6 +165,11 @@ public class UserWaterAlarmServiceImpl extends BaseServiceImpl<UserWaterAlarmMap
if (entity == null) {
continue;
}
if (entity.getStatus() == 3) {
continue;
} else if (entity.getStatus() == 5) {
continue;
}
entity.setStatus(3);
boolean result = this.editData(entity);
if (result) {
@@ -177,6 +182,11 @@ public class UserWaterAlarmServiceImpl extends BaseServiceImpl<UserWaterAlarmMap
if (entity == null) {
return response.failure("水质报警信息不存在");
}
if (entity.getStatus() == 3) {
return response.failure("水质报警已取消");
} else if (entity.getStatus() == 5) {
return response.failure("水质报警已完成,无法取消");
}
entity.setStatus(3);
boolean result = this.editData(entity);
if (!result) {
@@ -185,4 +195,19 @@ public class UserWaterAlarmServiceImpl extends BaseServiceImpl<UserWaterAlarmMap
return response.success("本次共取消【1】条报警数据");
}
}

/**
* 获取警告信息列表
*
* @param num 获取条数
* @return
*/
@Override
public Response getWaterAlarmList(Integer num) {
QueryWrapper<TauvWaterAlarm> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("status", 2);
queryWrapper.eq("mark", 1);
List<TauvWaterAlarm> waterAlarmList = userWaterAlarmMapper.selectList(queryWrapper);
return response.success(waterAlarmList);
}
}

Loading…
Cancel
Save