Преглед изворни кода

'地图接口修改'

master
daixiantong пре 4 година
родитељ
комит
0fba50613b
5 измењених фајлова са 179 додато и 65 уклоњено
  1. +2
    -1
      src/main/java/com/taauav/admin/service/ILsAdminService.java
  2. +138
    -56
      src/main/java/com/taauav/admin/service/impl/LsAdminServiceImpl.java
  3. +19
    -4
      src/main/java/com/taauav/common/util/FunctionUtils.java
  4. +6
    -4
      src/main/java/com/taauav/front/controller/LSAdminController.java
  5. +14
    -0
      src/main/java/com/taauav/front/vo/LSVillageVo.java

+ 2
- 1
src/main/java/com/taauav/admin/service/ILsAdminService.java Прегледај датотеку

@@ -10,6 +10,7 @@ import com.taauav.admin.query.LsAdminQuery;
import com.taauav.common.service.IBaseService;
import com.taauav.front.dto.LsInspectFileDTO;
import com.taauav.front.vo.LSAdminVo;
import com.taauav.front.vo.LSVillageVo;
import com.taauav.front.vo.SysCityVo;

import javax.validation.constraints.Max;
@@ -127,7 +128,7 @@ public interface ILsAdminService extends IBaseService<LsAdmin> {
* @param map
* @return
*/
List<SysCityVo> getVillageList(Integer userId, BigInteger cityId, Map<String, String> map);
LSVillageVo getVillageList(Integer userId, BigInteger cityId, Map<String, String> map);

/**
* 获取区域内所有河道问题坐标点

+ 138
- 56
src/main/java/com/taauav/admin/service/impl/LsAdminServiceImpl.java Прегледај датотеку

@@ -17,12 +17,14 @@ import com.taauav.common.bean.Response;
import com.taauav.common.constant.SysAdminConstant;
import com.taauav.common.service.impl.BaseServiceImpl;
import com.taauav.common.util.FunctionUtils;
import com.taauav.common.util.RedisUtils;
import com.taauav.common.util.StringUtils;
import com.taauav.admin.entity.LsAdmin;
import com.taauav.admin.mapper.LsAdminMapper;
import com.taauav.admin.query.LsAdminQuery;
import com.taauav.front.dto.LsInspectFileDTO;
import com.taauav.front.vo.LSAdminVo;
import com.taauav.front.vo.LSVillageVo;
import com.taauav.front.vo.LsInspectFileVo;
import com.taauav.front.vo.SysCityVo;
import org.springframework.beans.BeanUtils;
@@ -65,6 +67,8 @@ public class LsAdminServiceImpl extends BaseServiceImpl<LsAdminMapper, LsAdmin>
private TauvInspectFileMapper inspectFileMapper;
@Autowired
private ITauvDriverService driverService;
@Autowired
private RedisUtils redisUtils;

/**
* 获取数据列表
@@ -308,7 +312,7 @@ public class LsAdminServiceImpl extends BaseServiceImpl<LsAdminMapper, LsAdmin>

@Override
public LSAdminVo getAdminInfo(Integer userId) {
if (userId <= 0) {
if (userId == null || userId <= 0) {
return null;
}
LsAdmin admin = getInfo(userId);
@@ -483,45 +487,12 @@ public class LsAdminServiceImpl extends BaseServiceImpl<LsAdminMapper, LsAdmin>
* @return
*/
private SysCityVo countQuestion(SysCity city, Map<String, String> map) {
List<Map<String, Integer>> questionList = inspectFileMapper.countQuestionByArea(city.getId(), map);
SysCityVo cityVo = new SysCityVo();
BeanUtils.copyProperties(city, cityVo);
if (questionList.size() > 0) {
for (Map<String, Integer> question : questionList) {
Number number = (Number) question.get("number");
switch (question.get("category")) {
case 1:
cityVo.setSurfaceWater(number.intValue());
break;
case 2:
cityVo.setShoreLine(number.intValue());
break;
case 3:
cityVo.setOutfall(number.intValue());
break;
case 4:
cityVo.setWaterQuality(number.intValue());
break;
default:
break;
}
}
}
if (cityVo.getSurfaceWater() == null) {
cityVo.setSurfaceWater(0);
}
if (cityVo.getShoreLine() == null) {
cityVo.setShoreLine(0);
}
if (cityVo.getOutfall() == null) {
cityVo.setOutfall(0);
}
if (cityVo.getWaterQuality() == null) {
cityVo.setWaterQuality(0);
}
//计算问题数量
SysCityVo cityVo = countQuestionNum(city, map);
cityVo.setIsTrue(1);
List<TauvDriverDTO> driverList = driverService.getDriverListByCityId(cityVo.getId());
cityVo.setDriverList(driverList);
//获取区划内河道数据
List<TauvDriverDTO> driverDTOList = getDriverList(cityVo.getId());
cityVo.setDriverList(driverDTOList);
return cityVo;
}

@@ -533,7 +504,7 @@ public class LsAdminServiceImpl extends BaseServiceImpl<LsAdminMapper, LsAdmin>
* @return
*/
@Override
public List<SysCityVo> getVillageList(Integer userId, BigInteger townId, Map<String, String> map) {
public LSVillageVo getVillageList(Integer userId, BigInteger townId, Map<String, String> map) {
LsAdmin adminInfo = getInfo(userId);
if (adminInfo == null) {
return null;
@@ -552,6 +523,13 @@ public class LsAdminServiceImpl extends BaseServiceImpl<LsAdminMapper, LsAdmin>
wrapper.eq("status", 1);
wrapper.eq("mark", 1);
List<LsAuthGroup> authGroupList = authGroupService.list(wrapper);
String key = "userId_" + userId + "_townId_" + townId + "_village_driver";
Boolean exist = redisUtils.hasKey(key);
List<TauvDriverDTO> driverDTOList = new ArrayList<>();
if (exist) {
Object object = redisUtils.get(key);
driverDTOList = FunctionUtils.castList(object, TauvDriverDTO.class);
}
List<SysCityVo> cityVoList = new ArrayList<>();
List<SysCity> cityList = new ArrayList<>();
if (null != authGroupList && authGroupList.size() > 0) {
@@ -560,23 +538,39 @@ public class LsAdminServiceImpl extends BaseServiceImpl<LsAdminMapper, LsAdmin>
switch (auth.getAuthData()) {
case 1:
city = cityService.getInfoById(adminInfo.getDriverArea());
if (city.getLevel() == 5 && !cityList.contains(city) && city.getPid().equals(townId)) {
if (city.getLevel() == 5 && !cityList.contains(city)) {
cityList.add(city);
cityVoList.add(countQuestion(city, map));
if (city.getPid().equals(townId)) {
cityVoList.add(countQuestionNum(city, map));
}
if (!exist) {
driverDTOList = dealDriverList(city.getId(), driverDTOList);
}
}
break;
case 2:
city = cityService.getInfoById(adminInfo.getDriverArea());
if (city.getLevel() == 5 && !cityList.contains(city) && city.getPid().equals(townId)) {
if (city.getLevel() == 5 && !cityList.contains(city)) {
cityList.add(city);
cityVoList.add(countQuestion(city, map));
}
//获取子级
List<SysCity> childCityList = getChildCityList(adminInfo.getDriverArea(), 0);
for (SysCity item : childCityList) {
if (item.getPid().equals(townId) && !cityList.contains(item) && item.getLevel().equals(5)) {
cityList.add(item);
cityVoList.add(countQuestion(item, map));
if (city.getPid().equals(townId)) {
cityVoList.add(countQuestionNum(city, map));
}
if (!exist) {
driverDTOList = dealDriverList(city.getId(), driverDTOList);
}
} else if (city.getLevel() < 5) {
//获取子级
List<SysCity> childCityList = getChildCityList(adminInfo.getDriverArea(), 0);
for (SysCity item : childCityList) {
if (!cityList.contains(item) && item.getLevel().equals(5)) {
cityList.add(item);
if (item.getPid().equals(townId)) {
cityVoList.add(countQuestionNum(item, map));
}
if (!exist) {
driverDTOList = dealDriverList(city.getId(), driverDTOList);
}
}
}
}
break;
@@ -586,10 +580,15 @@ public class LsAdminServiceImpl extends BaseServiceImpl<LsAdminMapper, LsAdmin>
if (driverAreaList != null && driverAreaList.length > 0) {
for (String area : driverAreaList) {
BigInteger areaId = new BigInteger(area);
SysCity sysCity = cityService.getInfoById(areaId);
if (sysCity.getLevel().equals(5) && !cityList.contains(sysCity) && sysCity.getPid().equals(townId)) {
cityList.add(sysCity);
cityVoList.add(countQuestion(sysCity, map));
city = cityService.getInfoById(areaId);
if (city.getLevel().equals(5) && !cityList.contains(city)) {
cityList.add(city);
if (city.getPid().equals(townId)) {
cityVoList.add(countQuestionNum(city, map));
}
if (!exist) {
driverDTOList = dealDriverList(city.getId(), driverDTOList);
}
}
}
}
@@ -599,7 +598,13 @@ public class LsAdminServiceImpl extends BaseServiceImpl<LsAdminMapper, LsAdmin>
}
}
}
return cityVoList;
if (!exist && driverDTOList.size() > 0) {
redisUtils.set(key, driverDTOList, 86400);
}
LSVillageVo villageVo = new LSVillageVo();
villageVo.setCityVoList(cityVoList);
villageVo.setDriverDTOList(driverDTOList);
return villageVo;
}

/**
@@ -621,4 +626,81 @@ public class LsAdminServiceImpl extends BaseServiceImpl<LsAdminMapper, LsAdmin>
List<LsInspectFileVo> fileVoList = inspectFileMapper.getInspectFileList(inspectFileDTO);
return response.success(fileVoList);
}

/**
* 计算问题数量
* @param city
* @param map
* @return
*/
private SysCityVo countQuestionNum(SysCity city, Map<String, String> map) {
List<Map<String, Integer>> questionList = inspectFileMapper.countQuestionByArea(city.getId(), map);
SysCityVo cityVo = new SysCityVo();
BeanUtils.copyProperties(city, cityVo);
if (questionList.size() > 0) {
for (Map<String, Integer> question : questionList) {
Number number = (Number) question.get("number");
switch (question.get("category")) {
case 1:
cityVo.setSurfaceWater(number.intValue());
break;
case 2:
cityVo.setShoreLine(number.intValue());
break;
case 3:
cityVo.setOutfall(number.intValue());
break;
case 4:
cityVo.setWaterQuality(number.intValue());
break;
default:
break;
}
}
}
if (cityVo.getSurfaceWater() == null) {
cityVo.setSurfaceWater(0);
}
if (cityVo.getShoreLine() == null) {
cityVo.setShoreLine(0);
}
if (cityVo.getOutfall() == null) {
cityVo.setOutfall(0);
}
if (cityVo.getWaterQuality() == null) {
cityVo.setWaterQuality(0);
}
return cityVo;
}

/**
* 获取河道数据
* @param cityId
* @return
*/
private List<TauvDriverDTO> getDriverList(BigInteger cityId) {
List<TauvDriverDTO> driverList = driverService.getDriverListByCityId(cityId);
if (driverList == null) {
driverList = new ArrayList<>();
}
return driverList;
}

/**
* 处理河道数据
* @param cityId
* @param driverDTOList
* @return
*/
private List<TauvDriverDTO> dealDriverList(BigInteger cityId, List<TauvDriverDTO> driverDTOList) {
List<TauvDriverDTO> dtoList = getDriverList(cityId);
if (dtoList != null && dtoList.size() > 0) {
for (TauvDriverDTO driver : dtoList) {
if (!driverDTOList.contains(driver)) {
driverDTOList.add(driver);
}
}
}
return driverDTOList;
}
}

+ 19
- 4
src/main/java/com/taauav/common/util/FunctionUtils.java Прегледај датотеку

@@ -23,11 +23,8 @@ import java.net.HttpURLConnection;
import java.net.URL;
import java.security.MessageDigest;
import java.text.ParseException;
import java.util.Calendar;
import java.util.HashMap;
import java.util.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
/**
* 常用方法
@@ -414,4 +411,22 @@ public class FunctionUtils {
}
return map;
}
/**
* object 转 List
* @param object
* @param clazz
* @param <T>
* @return
*/
public static <T> List<T> castList(Object object, Class<T> clazz) {
List<T> result = new ArrayList<>();
if (object instanceof List<?>) {
for (Object o : (List<?>) object) {
result.add(clazz.cast(o));
}
return result;
}
return null;
}
}

+ 6
- 4
src/main/java/com/taauav/front/controller/LSAdminController.java Прегледај датотеку

@@ -9,6 +9,7 @@ import com.taauav.common.bean.Response;
import com.taauav.common.util.StringUtils;
import com.taauav.front.dto.LsInspectFileDTO;
import com.taauav.front.vo.LSAdminVo;
import com.taauav.front.vo.LSVillageVo;
import com.taauav.front.vo.SysCityVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
@@ -36,7 +37,6 @@ public class LSAdminController extends FrontBaseController {

/**
* 获取地图权限内区、镇/街道级数据
* @param userId
* @param map
* @return
*/
@@ -46,7 +46,9 @@ public class LSAdminController extends FrontBaseController {

//数据权限处理
List<SysCityVo> cityList = lsAdminService.getAdminAreaList(info, map);
info.setCityList(cityList);
if (cityList != null) {
info.setCityList(cityList);
}

return response.success(info);
}
@@ -58,8 +60,8 @@ public class LSAdminController extends FrontBaseController {
*/
@GetMapping("/village")
public Response getVillageData(@RequestParam("userId")Integer userId, @RequestParam("townId") BigInteger townId, @RequestParam Map<String, String> map) {
List<SysCityVo> villageList = lsAdminService.getVillageList(userId, townId, map);
return response.success(villageList);
LSVillageVo village = lsAdminService.getVillageList(userId, townId, map);
return response.success(village);
}

/**

+ 14
- 0
src/main/java/com/taauav/front/vo/LSVillageVo.java Прегледај датотеку

@@ -0,0 +1,14 @@
package com.taauav.front.vo;

import com.taauav.admin.dto.TauvDriverDTO;
import lombok.Data;

import java.util.List;

@Data
public class LSVillageVo {

private List<SysCityVo> cityVoList;

private List<TauvDriverDTO> driverDTOList;
}

Loading…
Откажи
Сачувај