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