2021-07-13 10:18:08 +08:00
|
|
|
|
package com.xkrs.service.impl;
|
|
|
|
|
|
2021-07-16 09:52:25 +08:00
|
|
|
|
import com.xkrs.common.encapsulation.PromptMessageEnum;
|
|
|
|
|
import com.xkrs.common.tool.TokenUtil;
|
2021-07-16 10:47:24 +08:00
|
|
|
|
import com.xkrs.dao.*;
|
|
|
|
|
import com.xkrs.model.entity.*;
|
2021-07-13 10:18:08 +08:00
|
|
|
|
import com.xkrs.model.qo.FirePointQo;
|
2021-07-16 11:12:37 +08:00
|
|
|
|
import com.xkrs.model.vo.AppPhotoVo;
|
2021-07-16 10:47:24 +08:00
|
|
|
|
import com.xkrs.model.vo.AppTaskBodyVo;
|
2021-07-13 10:18:08 +08:00
|
|
|
|
import com.xkrs.service.FirePointService;
|
2021-07-16 10:47:24 +08:00
|
|
|
|
import com.xkrs.utils.*;
|
2021-07-14 17:35:10 +08:00
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
2021-12-01 14:13:05 +08:00
|
|
|
|
import org.springframework.cache.annotation.CacheConfig;
|
|
|
|
|
import org.springframework.cache.annotation.CacheEvict;
|
|
|
|
|
import org.springframework.cache.annotation.Cacheable;
|
2021-07-16 11:12:37 +08:00
|
|
|
|
import org.springframework.cglib.beans.BeanCopier;
|
2021-07-16 09:52:25 +08:00
|
|
|
|
import org.springframework.context.i18n.LocaleContextHolder;
|
2021-07-13 10:18:08 +08:00
|
|
|
|
import org.springframework.stereotype.Service;
|
2021-07-16 10:47:24 +08:00
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
2021-07-13 10:18:08 +08:00
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
2021-07-16 09:52:25 +08:00
|
|
|
|
import javax.transaction.Transactional;
|
2021-07-16 10:47:24 +08:00
|
|
|
|
import java.io.IOException;
|
2021-07-15 15:22:23 +08:00
|
|
|
|
import java.time.LocalDate;
|
2021-07-13 10:18:08 +08:00
|
|
|
|
import java.time.LocalDateTime;
|
2021-09-24 15:19:36 +08:00
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
2021-07-16 09:52:25 +08:00
|
|
|
|
|
|
|
|
|
import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
|
2021-07-13 10:18:08 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author XinYi Song
|
|
|
|
|
*/
|
2021-12-01 14:13:05 +08:00
|
|
|
|
@CacheConfig(cacheNames = "FirePointServiceCache")
|
2021-07-13 10:18:08 +08:00
|
|
|
|
@Service
|
|
|
|
|
public class FirePointServiceImpl implements FirePointService {
|
|
|
|
|
|
2021-07-14 17:35:10 +08:00
|
|
|
|
public static Logger log = LoggerFactory.getLogger(FirePointServiceImpl.class);
|
|
|
|
|
|
2021-07-13 10:18:08 +08:00
|
|
|
|
@Resource
|
|
|
|
|
private FirePointDao firePointDao;
|
|
|
|
|
|
2021-07-16 09:22:48 +08:00
|
|
|
|
@Resource
|
|
|
|
|
private Query query;
|
|
|
|
|
|
2021-07-16 09:52:25 +08:00
|
|
|
|
@Resource
|
|
|
|
|
private SysUserDao sysUserDao;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private FireAndRangerDao fireAndRangerDao;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private ForestRangerDao forestRangerDao;
|
|
|
|
|
|
2021-07-16 10:47:24 +08:00
|
|
|
|
@Resource
|
|
|
|
|
private FireTaskDao fireTaskDao;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private JdbcUtils jdbcUtils;
|
|
|
|
|
|
2021-07-16 11:12:37 +08:00
|
|
|
|
@Resource
|
|
|
|
|
private FireTaskPhotoDao fireTaskPhotoDao;
|
|
|
|
|
|
2021-07-22 11:54:01 +08:00
|
|
|
|
@Resource
|
|
|
|
|
private CityDao cityDao;
|
|
|
|
|
|
2021-08-02 17:05:11 +08:00
|
|
|
|
@Resource
|
|
|
|
|
private CountyDao countyDao;
|
|
|
|
|
|
2021-09-23 16:36:08 +08:00
|
|
|
|
@Resource
|
|
|
|
|
private FireDao fireDao;
|
|
|
|
|
|
2021-09-24 15:19:36 +08:00
|
|
|
|
@Resource
|
|
|
|
|
private NationwideDao nationwideDao;
|
|
|
|
|
|
2021-07-13 10:18:08 +08:00
|
|
|
|
/**
|
|
|
|
|
* 添加火点信息
|
2022-05-06 17:49:37 +08:00
|
|
|
|
*
|
2021-07-13 10:18:08 +08:00
|
|
|
|
* @param firePointQo
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-05-06 17:49:37 +08:00
|
|
|
|
@CacheEvict(value = "FirePointServiceCache", allEntries = true)
|
2021-07-13 10:18:08 +08:00
|
|
|
|
@Override
|
|
|
|
|
public FirePointEntity insertFirePoint(FirePointQo firePointQo) {
|
|
|
|
|
FirePointEntity firePointEntity = new FirePointEntity();
|
2022-05-06 17:49:37 +08:00
|
|
|
|
if (firePointQo.getLandtype().equals("水体")) {
|
2021-10-11 16:28:03 +08:00
|
|
|
|
return null;
|
2022-05-06 17:49:37 +08:00
|
|
|
|
} else if ("Himawari 8".equals(firePointQo.getSatelliteType()) && "L".equals(firePointQo.getConfidence())) {
|
2021-12-01 14:13:05 +08:00
|
|
|
|
return null;
|
2022-05-06 17:49:37 +08:00
|
|
|
|
} else if ("Himawari 8".equals(firePointQo.getSatelliteType()) && "N".equals(firePointQo.getConfidence())) {
|
2021-12-01 14:13:05 +08:00
|
|
|
|
return null;
|
2022-05-06 17:49:37 +08:00
|
|
|
|
} else {
|
2021-10-11 16:28:03 +08:00
|
|
|
|
firePointEntity.setFireCode(firePointQo.getFireCode());
|
|
|
|
|
firePointEntity.setCountyCode(firePointQo.getCountyCode().toString());
|
|
|
|
|
firePointEntity.setCountyName(firePointQo.getCountyName());
|
|
|
|
|
firePointEntity.setSatelliteTime(DateTimeUtil.timeMillisToString(firePointQo.getSatelliteTimeTs().longValue()));
|
|
|
|
|
firePointEntity.setLongitude(firePointQo.getLongitude());
|
|
|
|
|
firePointEntity.setLatitude(firePointQo.getLatitude());
|
2022-05-06 17:49:37 +08:00
|
|
|
|
firePointEntity.setFirePointAddress(AddressUtils.getLocal(firePointQo.getLatitude().toString(), firePointQo.getLongitude().toString()));
|
2021-10-11 16:28:03 +08:00
|
|
|
|
firePointEntity.setSatelliteType(firePointQo.getSatelliteType());
|
|
|
|
|
firePointEntity.setLandType(firePointQo.getLandtype());
|
|
|
|
|
firePointEntity.setConfidence(firePointQo.getConfidence());
|
|
|
|
|
firePointEntity.setAddTime(DateTimeUtil.dateTimeToString(LocalDateTime.now()));
|
|
|
|
|
firePointEntity.setFireType("0");
|
|
|
|
|
firePointEntity.setFireImage(firePointQo.getFireImage());
|
|
|
|
|
firePointEntity.setSatelliteImage(firePointQo.getSatelliteImage());
|
|
|
|
|
log.info("-------发现新火点");
|
2021-07-30 17:41:02 +08:00
|
|
|
|
/*log.info("---------------开始进行实时通讯,将检测到的火点传给前端");
|
2021-07-20 16:38:14 +08:00
|
|
|
|
Map map = new HashMap(3);
|
|
|
|
|
map.put("countyCode",firePointQo.getCountyCode());
|
|
|
|
|
map.put("countyName",firePointQo.getCountyName());
|
|
|
|
|
map.put("fireCode",firePointQo.getFireCode());
|
|
|
|
|
map.put("latitude",firePointQo.getLatitude());
|
|
|
|
|
map.put("longitude",firePointQo.getLongitude());
|
|
|
|
|
map.put("satelliteTime",DateTimeUtil.timeMillisToString(firePointQo.getSatelliteTimeTs().longValue()));
|
|
|
|
|
map.put("satelliteType",firePointQo.getSatelliteType());
|
|
|
|
|
map.put("addTime",DateTimeUtil.dateTimeToString(LocalDateTime.now()));
|
|
|
|
|
map.put("detailedAddress",AddressUtils.getLatAndLng(firePointQo.getLatitude().toString(),firePointQo.getLongitude().toString()));
|
|
|
|
|
Map map1 = new HashMap(3);
|
|
|
|
|
map1.put("fire",map);
|
|
|
|
|
String websocket = JSON.toJSONString(map1);
|
|
|
|
|
// 将监测到的火点信息返给前端
|
2021-07-30 17:41:02 +08:00
|
|
|
|
WebSocketServer.broadInfo(websocket);*/
|
2021-10-11 16:28:03 +08:00
|
|
|
|
return firePointDao.save(firePointEntity);
|
|
|
|
|
}
|
2021-07-13 10:18:08 +08:00
|
|
|
|
}
|
2021-07-15 15:22:23 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询今天的火点信息
|
2022-05-06 17:49:37 +08:00
|
|
|
|
*
|
2021-07-15 15:22:23 +08:00
|
|
|
|
* @param
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-05-06 17:49:37 +08:00
|
|
|
|
@Cacheable(keyGenerator = "keyGenerator", unless = "#result == null")
|
2021-07-15 15:22:23 +08:00
|
|
|
|
@Override
|
2021-08-02 14:56:25 +08:00
|
|
|
|
public List<FirePointEntity> selectTodayFirePoint(String countyCode) {
|
2021-07-15 15:22:23 +08:00
|
|
|
|
String addTime = DateTimeUtil.dateToString(LocalDate.now());
|
2022-05-06 17:49:37 +08:00
|
|
|
|
if ("0000".equals(countyCode.substring(2))) {
|
2021-08-05 15:53:42 +08:00
|
|
|
|
List<CityEntity> byProCode = cityDao.findByProCode(countyCode);
|
|
|
|
|
String proName = byProCode.get(0).getProName();
|
2022-04-29 11:34:05 +08:00
|
|
|
|
// if(proName.equals("山东省")){
|
|
|
|
|
// return firePointDao.selectTodayFirePointShandong(addTime,proName);
|
|
|
|
|
// }
|
2022-05-06 17:49:37 +08:00
|
|
|
|
return firePointDao.selectTodayFirePoint(addTime, proName);
|
2022-04-29 11:34:05 +08:00
|
|
|
|
|
2022-05-06 17:49:37 +08:00
|
|
|
|
} else if ("00".equals(countyCode.substring(4)) && !"0000".equals(countyCode.substring(2))) {
|
2021-08-11 11:21:05 +08:00
|
|
|
|
List<CountyEntity> byCityCode = countyDao.findByCityCode(countyCode);
|
2021-08-05 15:53:42 +08:00
|
|
|
|
String cityName = byCityCode.get(0).getCityName();
|
2021-12-07 08:32:55 +08:00
|
|
|
|
CityEntity byCityName = cityDao.findByCityName(cityName);
|
2022-04-29 11:34:05 +08:00
|
|
|
|
// if(byCityName.getProName().equals("山东省")){
|
|
|
|
|
// return firePointDao.selectTodayFirePointShandong(addTime,cityName);
|
|
|
|
|
// }
|
2022-05-06 17:49:37 +08:00
|
|
|
|
return firePointDao.selectTodayFirePoint(addTime, cityName);
|
|
|
|
|
} else {
|
|
|
|
|
List<CountyEntity> byCountyCode = countyDao.findByCountyCode(countyCode);
|
|
|
|
|
CityEntity byCityName = cityDao.findByCityName(byCountyCode.get(0).getCityName());
|
2022-04-29 11:34:05 +08:00
|
|
|
|
// if(b
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// yCityName.getProName().equals("山东省")){
|
|
|
|
|
// return firePointDao.selectTodayFirePointOneShandong(addTime,countyCode);
|
|
|
|
|
// }
|
2022-05-06 17:49:37 +08:00
|
|
|
|
return firePointDao.selectTodayFirePointOne(addTime, countyCode);
|
2021-08-02 14:56:25 +08:00
|
|
|
|
}
|
2021-07-15 15:22:23 +08:00
|
|
|
|
}
|
2021-07-16 09:22:48 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2021-08-02 14:22:45 +08:00
|
|
|
|
* 动态多条件查询火点信息(省)
|
2022-05-06 17:49:37 +08:00
|
|
|
|
*
|
2021-07-16 09:22:48 +08:00
|
|
|
|
* @param cityCode
|
|
|
|
|
* @param satelliteType
|
|
|
|
|
* @param landType
|
|
|
|
|
* @param startTime
|
|
|
|
|
* @param endTime
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-05-06 17:49:37 +08:00
|
|
|
|
@Cacheable(keyGenerator = "keyGenerator", unless = "#result == null")
|
2021-07-16 09:22:48 +08:00
|
|
|
|
@Override
|
2022-05-06 17:49:37 +08:00
|
|
|
|
public List<FirePointEntity> selectFirePoint(String proCode, String cityCode, String satelliteType, String landType, String startTime, String endTime) {
|
2021-08-05 15:53:42 +08:00
|
|
|
|
List<CityEntity> byProCode = cityDao.findByProCode(proCode);
|
|
|
|
|
String proName = byProCode.get(0).getProName();
|
2022-05-06 17:49:37 +08:00
|
|
|
|
if (!"".equals(startTime) && !"".equals(endTime)) {
|
2021-12-06 09:03:07 +08:00
|
|
|
|
LocalDate localDate = DateTimeUtil.stringToDate(endTime);
|
|
|
|
|
// 结束时间
|
|
|
|
|
LocalDate localDate1 = localDate.plusDays(1);
|
|
|
|
|
String dateToString = DateTimeUtil.dateToString(localDate1);
|
2022-05-06 17:49:37 +08:00
|
|
|
|
return query.selectFirePointByPro(proName, cityCode, satelliteType, landType, startTime, dateToString);
|
2021-12-06 09:03:07 +08:00
|
|
|
|
}
|
2022-05-06 17:49:37 +08:00
|
|
|
|
return query.selectFirePointByPro(proName, cityCode, satelliteType, landType, startTime, endTime);
|
2021-08-02 14:22:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 动态多条件查询火点信息(市)
|
2022-05-06 17:49:37 +08:00
|
|
|
|
*
|
|
|
|
|
* @param cityCodeOne 市编码
|
|
|
|
|
* @param cityCode 县编码
|
2021-08-02 14:22:45 +08:00
|
|
|
|
* @param satelliteType
|
|
|
|
|
* @param landType
|
|
|
|
|
* @param startTime
|
|
|
|
|
* @param endTime
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-05-06 17:49:37 +08:00
|
|
|
|
@Cacheable(keyGenerator = "keyGenerator", unless = "#result == null")
|
2021-08-02 14:22:45 +08:00
|
|
|
|
@Override
|
|
|
|
|
public List<FirePointEntity> selectFirePointByCity(String cityCodeOne, String cityCode, String satelliteType, String landType, String startTime, String endTime) {
|
2021-09-23 16:36:08 +08:00
|
|
|
|
//List<CityEntity> byCityCode = cityDao.findByCityCode(cityCodeOne.substring(0,3));
|
|
|
|
|
List<CountyEntity> byCityCode = countyDao.findByCityCode(cityCodeOne);
|
2021-08-05 15:53:42 +08:00
|
|
|
|
String cityName = byCityCode.get(0).getCityName();
|
2021-12-07 08:32:55 +08:00
|
|
|
|
CityEntity byCityCode1 = cityDao.findByCityName(cityName);
|
|
|
|
|
String proName = byCityCode1.getProName();
|
2022-05-06 17:49:37 +08:00
|
|
|
|
if (!"".equals(startTime) && !"".equals(endTime)) {
|
2021-12-06 09:03:07 +08:00
|
|
|
|
LocalDate localDate = DateTimeUtil.stringToDate(endTime);
|
|
|
|
|
// 结束时间
|
|
|
|
|
LocalDate localDate1 = localDate.plusDays(1);
|
|
|
|
|
String dateToString = DateTimeUtil.dateToString(localDate1);
|
2022-05-06 17:49:37 +08:00
|
|
|
|
return query.selectFirePointByCity(proName, cityName, cityCode, satelliteType, landType, startTime, dateToString);
|
2021-12-06 09:03:07 +08:00
|
|
|
|
}
|
2022-05-06 17:49:37 +08:00
|
|
|
|
return query.selectFirePointByCity(proName, cityName, cityCode, satelliteType, landType, startTime, endTime);
|
2021-08-02 14:22:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 动态多条件查询火点信息(县)
|
2022-05-06 17:49:37 +08:00
|
|
|
|
*
|
|
|
|
|
* @param cityCode 县编码
|
2021-08-02 14:22:45 +08:00
|
|
|
|
* @param satelliteType
|
|
|
|
|
* @param landType
|
|
|
|
|
* @param startTime
|
|
|
|
|
* @param endTime
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-05-06 17:49:37 +08:00
|
|
|
|
@Cacheable(keyGenerator = "keyGenerator", unless = "#result == null")
|
2021-08-02 14:22:45 +08:00
|
|
|
|
@Override
|
|
|
|
|
public List<FirePointEntity> selectFirePointByCounty(String cityCode, String satelliteType, String landType, String startTime, String endTime) {
|
2021-12-06 09:03:07 +08:00
|
|
|
|
|
2022-05-06 17:49:37 +08:00
|
|
|
|
List<CountyEntity> byCountyCode = countyDao.findByCountyCode(cityCode);
|
|
|
|
|
CityEntity byCityCode = cityDao.findByCityName(byCountyCode.get(0).getCityName());
|
2021-12-07 08:32:55 +08:00
|
|
|
|
String proName = byCityCode.getProName();
|
2022-05-06 17:49:37 +08:00
|
|
|
|
if (!"".equals(startTime) && !"".equals(endTime)) {
|
2021-12-06 09:03:07 +08:00
|
|
|
|
LocalDate localDate = DateTimeUtil.stringToDate(endTime);
|
|
|
|
|
// 结束时间
|
|
|
|
|
LocalDate localDate1 = localDate.plusDays(1);
|
|
|
|
|
String dateToString = DateTimeUtil.dateToString(localDate1);
|
2022-05-06 17:49:37 +08:00
|
|
|
|
return query.selectFirePointByCounty(proName, cityCode, satelliteType, landType, startTime, dateToString);
|
2021-12-06 09:03:07 +08:00
|
|
|
|
}
|
2022-05-06 17:49:37 +08:00
|
|
|
|
return query.selectFirePointByCounty(proName, cityCode, satelliteType, landType, startTime, endTime);
|
2021-07-16 09:22:48 +08:00
|
|
|
|
}
|
2021-07-16 09:52:25 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据火点编码修改火点的状态(预警)
|
2022-05-06 17:49:37 +08:00
|
|
|
|
*
|
2021-07-16 09:52:25 +08:00
|
|
|
|
* @param fireCode
|
|
|
|
|
* @param fireType
|
|
|
|
|
* @param token
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Transactional(rollbackOn = Exception.class)
|
|
|
|
|
@Override
|
|
|
|
|
public String updateTypeByFireCode(String fireCode, String fireType, String token) {
|
|
|
|
|
// 获取区域信息
|
|
|
|
|
Locale locale = LocaleContextHolder.getLocale();
|
|
|
|
|
String tokenUserName = TokenUtil.getTokenUserName(token);
|
|
|
|
|
SysUserEntity sysUserEntity = sysUserDao.selectByUserName(tokenUserName);
|
|
|
|
|
FirePointEntity byFireCode = firePointDao.findByFireCode(fireCode);
|
2021-08-06 16:39:16 +08:00
|
|
|
|
if ("3".equals(byFireCode.getFireType()) || "-1".equals(byFireCode.getFireType())) {
|
2022-05-06 17:49:37 +08:00
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "该火点已经结案,请勿进行有关状态操作", locale);
|
2021-07-16 09:52:25 +08:00
|
|
|
|
}
|
|
|
|
|
if (fireType.equals(byFireCode.getFireType())) {
|
2022-05-06 17:49:37 +08:00
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "您正处于当前的状态,请勿进行该操作", locale);
|
2021-07-16 09:52:25 +08:00
|
|
|
|
}
|
|
|
|
|
firePointDao.updateFireTypeByFireCode(fireCode, fireType);
|
2021-08-06 16:39:16 +08:00
|
|
|
|
if ("1".equals(fireType)) {
|
2021-07-16 09:52:25 +08:00
|
|
|
|
FirePointEntity byFireCode1 = firePointDao.findByFireCode(fireCode);
|
|
|
|
|
// 预警
|
2022-05-06 17:49:37 +08:00
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, byFireCode1, locale);
|
|
|
|
|
} else if ("2".equals(fireType)) {
|
2021-07-16 09:52:25 +08:00
|
|
|
|
FirePointEntity byFireCode3 = firePointDao.findByFireCode(fireCode);
|
|
|
|
|
// 核查
|
2022-05-06 17:49:37 +08:00
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, byFireCode3, locale);
|
2021-07-16 09:52:25 +08:00
|
|
|
|
} else {
|
|
|
|
|
String rangerType = "0";
|
|
|
|
|
FireAndRanger byFireCode1 = fireAndRangerDao.findByFireCode(fireCode);
|
|
|
|
|
if (byFireCode1 == null) {
|
|
|
|
|
FirePointEntity byFireCode4 = firePointDao.findByFireCode(fireCode);
|
|
|
|
|
String time = DateTimeUtil.dateTimeToString(LocalDateTime.now());
|
|
|
|
|
FireAndRanger fireAndRanger = new FireAndRanger();
|
|
|
|
|
fireAndRanger.setFireCode(fireCode);
|
|
|
|
|
// 由于测试阶段先用用户账号代替,后期换成getReallyName(用户真实姓名)
|
|
|
|
|
fireAndRanger.setHandler(sysUserEntity.getReallyName());
|
|
|
|
|
fireAndRanger.setEndTime(time);
|
|
|
|
|
fireAndRangerDao.save(fireAndRanger);
|
|
|
|
|
// 结案
|
2022-05-06 17:49:37 +08:00
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, byFireCode4, locale);
|
2021-07-16 09:52:25 +08:00
|
|
|
|
}
|
|
|
|
|
// 火点结案,将护林员的状态修改为0 表示该护林员没有在执行任务,处于空闲状态
|
|
|
|
|
forestRangerDao.updateRangerTypeByPhone(byFireCode1.getRangerName(), rangerType);
|
|
|
|
|
String time = DateTimeUtil.dateTimeToString(LocalDateTime.now());
|
|
|
|
|
fireAndRangerDao.updateEndTimeByFireCode(fireCode, time);
|
|
|
|
|
fireAndRangerDao.updateProgressTypeByFireCode(fireCode, "0");
|
2022-05-06 17:49:37 +08:00
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "结案", locale);
|
2021-07-16 09:52:25 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-07-16 10:47:24 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 提交核查任务
|
2022-05-06 17:49:37 +08:00
|
|
|
|
*
|
2021-07-16 10:47:24 +08:00
|
|
|
|
* @param files
|
|
|
|
|
* @param appTaskBodyVo
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Transactional(rollbackOn = Exception.class)
|
|
|
|
|
@Override
|
|
|
|
|
public String insertAppTask(MultipartFile[] files, AppTaskBodyVo appTaskBodyVo) throws IOException {
|
|
|
|
|
// 获取区域信息
|
|
|
|
|
Locale locale = LocaleContextHolder.getLocale();
|
|
|
|
|
FirePointEntity byFireCode = firePointDao.findByFireCode(appTaskBodyVo.getFireCode());
|
2022-05-06 17:49:37 +08:00
|
|
|
|
if (byFireCode == null) {
|
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "火点编码错误,请重新输入", locale);
|
2021-07-16 10:47:24 +08:00
|
|
|
|
}
|
|
|
|
|
FireTask byTaskFireCode = fireTaskDao.findByTaskFireCode(appTaskBodyVo.getFireCode());
|
2022-05-06 17:49:37 +08:00
|
|
|
|
if (byTaskFireCode != null) {
|
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "该火点的任务已经提交,请勿重复提交", locale);
|
2021-07-16 10:47:24 +08:00
|
|
|
|
}
|
|
|
|
|
String s = DateTimeUtil.dateTimeToString(LocalDateTime.now());
|
|
|
|
|
FireTask fireTask = new FireTask();
|
|
|
|
|
fireTask.setTaskFireCode(appTaskBodyVo.getFireCode());
|
|
|
|
|
fireTask.setTaskInformation(appTaskBodyVo.getTaskInformation());
|
|
|
|
|
fireTask.setTaskTime(s);
|
|
|
|
|
FireTask save = fireTaskDao.save(fireTask);
|
2022-05-06 17:49:37 +08:00
|
|
|
|
if (save == null) {
|
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "任务提交失败", locale);
|
2021-07-16 10:47:24 +08:00
|
|
|
|
}
|
|
|
|
|
List<FireTaskPhoto> fireTaskPhotos = PhotoUtil.uploadImage(files, appTaskBodyVo.getFireCode());
|
2021-07-26 14:34:52 +08:00
|
|
|
|
List<FireTaskPhoto> fireTaskPhotos1 = fireTaskPhotoDao.saveAll(fireTaskPhotos);
|
2022-05-06 17:49:37 +08:00
|
|
|
|
if (fireTaskPhotos1 == null || fireTaskPhotos1.size() == 0) {
|
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "图片上传失败,任务提交失败", locale);
|
2021-07-16 10:47:24 +08:00
|
|
|
|
}
|
2022-05-06 17:49:37 +08:00
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "任务提交成功", locale);
|
2021-07-16 11:12:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据火点编码查询任务信息
|
2022-05-06 17:49:37 +08:00
|
|
|
|
*
|
2021-07-16 11:12:37 +08:00
|
|
|
|
* @param fireCode
|
|
|
|
|
* @return
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public String selectAppTask(String fireCode) throws Exception {
|
|
|
|
|
// 获取区域信息
|
|
|
|
|
Locale locale = LocaleContextHolder.getLocale();
|
|
|
|
|
FireTask byTaskFireCode = fireTaskDao.findByTaskFireCode(fireCode);
|
2022-05-06 17:49:37 +08:00
|
|
|
|
if (byTaskFireCode == null) {
|
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时还没有该火点的任务信息", locale);
|
2021-07-16 11:12:37 +08:00
|
|
|
|
}
|
|
|
|
|
AppTaskBodyVo appTaskBodyVo = new AppTaskBodyVo();
|
|
|
|
|
// 做映射,返回vo类对象
|
|
|
|
|
BeanCopier beanCopier = BeanCopier.create(FireTask.class, AppTaskBodyVo.class, false);
|
2022-05-06 17:49:37 +08:00
|
|
|
|
beanCopier.copy(byTaskFireCode, appTaskBodyVo, null);
|
2021-07-16 11:12:37 +08:00
|
|
|
|
|
|
|
|
|
List<Object[]> photoPath = fireTaskPhotoDao.findPhotoPath(fireCode);
|
|
|
|
|
List<AppPhotoVo> appPhotoVos = ObjectToBeanUtils.objectToBean(photoPath, AppPhotoVo.class);
|
|
|
|
|
appTaskBodyVo.setTaskFirePhoto(appPhotoVos);
|
|
|
|
|
|
2022-05-06 17:49:37 +08:00
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, appTaskBodyVo, locale);
|
2021-07-16 10:47:24 +08:00
|
|
|
|
}
|
2021-07-16 17:21:31 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询近一周的火点信息
|
2022-05-06 17:49:37 +08:00
|
|
|
|
*
|
2021-07-16 17:21:31 +08:00
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-05-06 17:49:37 +08:00
|
|
|
|
@Cacheable(keyGenerator = "keyGenerator", unless = "#result == null")
|
2021-07-16 17:21:31 +08:00
|
|
|
|
@Override
|
|
|
|
|
public List<FirePointEntity> selectFirePointBetweenSeven() {
|
|
|
|
|
LocalDateTime localDateTime = LocalDateTime.now();
|
|
|
|
|
String endTime = DateTimeUtil.dateTimeToString(localDateTime);
|
|
|
|
|
|
|
|
|
|
// 当前时间减7
|
|
|
|
|
LocalDateTime localDateTime1 = localDateTime.minusDays(7);
|
|
|
|
|
String startTime = DateTimeUtil.dateTimeToString(localDateTime1);
|
|
|
|
|
return query.selectFirePointBetweenThree(startTime, endTime);
|
|
|
|
|
}
|
2021-07-19 10:51:05 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询近一个月的火点信息
|
2022-05-06 17:49:37 +08:00
|
|
|
|
*
|
2021-07-19 10:51:05 +08:00
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-05-06 17:49:37 +08:00
|
|
|
|
@Cacheable(keyGenerator = "keyGenerator", unless = "#result == null")
|
2021-07-19 10:51:05 +08:00
|
|
|
|
@Override
|
2021-08-05 15:53:42 +08:00
|
|
|
|
public List<FirePointEntity> selectFirePointByMonth(String countyCode) {
|
2021-07-19 10:51:05 +08:00
|
|
|
|
LocalDateTime localDateTime = LocalDateTime.now();
|
|
|
|
|
String endTime = DateTimeUtil.dateTimeToString(localDateTime);
|
2021-12-07 08:32:55 +08:00
|
|
|
|
// 当前时间减31
|
2021-08-05 15:53:42 +08:00
|
|
|
|
LocalDateTime localDateTime1 = localDateTime.minusDays(31);
|
2021-07-19 10:51:05 +08:00
|
|
|
|
String startTime = DateTimeUtil.dateTimeToString(localDateTime1);
|
2022-05-06 17:49:37 +08:00
|
|
|
|
if ("0000".equals(countyCode.substring(2))) {
|
2021-08-05 15:53:42 +08:00
|
|
|
|
List<CityEntity> byProCode = cityDao.findByProCode(countyCode);
|
|
|
|
|
String proName = byProCode.get(0).getProName();
|
2022-05-06 17:49:37 +08:00
|
|
|
|
return query.selectFirePointByMonth(proName, startTime, endTime);
|
|
|
|
|
} else if ("00".equals(countyCode.substring(4)) && !"0000".equals(countyCode.substring(2))) {
|
2021-08-11 11:21:05 +08:00
|
|
|
|
List<CountyEntity> byCityCode = countyDao.findByCityCode(countyCode);
|
2021-08-05 15:53:42 +08:00
|
|
|
|
String cityName = byCityCode.get(0).getCityName();
|
2021-12-07 08:32:55 +08:00
|
|
|
|
CityEntity byCityName = cityDao.findByCityName(cityName);
|
|
|
|
|
String proName = byCityName.getProName();
|
2022-05-06 17:49:37 +08:00
|
|
|
|
return query.selectFirePointByMonthCity(proName, cityName, startTime, endTime);
|
|
|
|
|
} else {
|
|
|
|
|
List<CountyEntity> byCountyCode = countyDao.findByCountyCode(countyCode);
|
|
|
|
|
CityEntity byCityName = cityDao.findByCityName(byCountyCode.get(0).getCityName());
|
2021-12-07 08:32:55 +08:00
|
|
|
|
String proName = byCityName.getProName();
|
2022-05-06 17:49:37 +08:00
|
|
|
|
return query.selectFirePointByMonthCounty(proName, countyCode, startTime, endTime);
|
2021-08-05 15:53:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-07-19 10:51:05 +08:00
|
|
|
|
}
|
2021-07-20 15:07:37 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询近一个月的火点数量
|
2022-05-06 17:49:37 +08:00
|
|
|
|
*
|
2021-07-20 15:07:37 +08:00
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-05-06 17:49:37 +08:00
|
|
|
|
@Cacheable(keyGenerator = "keyGenerator", unless = "#result == null")
|
2021-07-20 15:07:37 +08:00
|
|
|
|
@Override
|
|
|
|
|
public String selectFirePointNumMonth() {
|
|
|
|
|
// 获取区域信息
|
|
|
|
|
Locale locale = LocaleContextHolder.getLocale();
|
|
|
|
|
Map map = new HashMap(3);
|
|
|
|
|
LocalDateTime localDateTime = LocalDateTime.now();
|
|
|
|
|
LocalDateTime localDateTime2 = localDateTime.plusDays(1);
|
|
|
|
|
String endTime = DateTimeUtil.dateTimeToString(localDateTime2);
|
|
|
|
|
// 当前时间减30
|
|
|
|
|
LocalDateTime localDateTime1 = localDateTime.minusDays(30);
|
|
|
|
|
String startTime = DateTimeUtil.dateTimeToString(localDateTime1);
|
|
|
|
|
// 查询近一个月各植被类型的火点数量
|
|
|
|
|
List<Map<String, Object>> maps = firePointDao.selectNumByLandType(startTime, endTime);
|
2022-05-06 17:49:37 +08:00
|
|
|
|
map.put("land", maps);
|
2021-07-20 15:07:37 +08:00
|
|
|
|
// 查询近一个月各地区火点数量
|
|
|
|
|
List<Map<String, Object>> maps1 = firePointDao.selectNumByArea(startTime, endTime);
|
2022-05-06 17:49:37 +08:00
|
|
|
|
map.put("area", maps1);
|
2021-07-20 15:07:37 +08:00
|
|
|
|
|
2022-05-06 17:49:37 +08:00
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, map, locale);
|
2021-07-20 15:07:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询近一天的火点数量
|
2022-05-06 17:49:37 +08:00
|
|
|
|
*
|
2021-07-20 15:07:37 +08:00
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-05-06 17:49:37 +08:00
|
|
|
|
@Cacheable(keyGenerator = "keyGenerator", unless = "#result == null")
|
2021-07-20 15:07:37 +08:00
|
|
|
|
@Override
|
|
|
|
|
public String selectFirePointNumDay() {
|
|
|
|
|
// 获取区域信息
|
|
|
|
|
Locale locale = LocaleContextHolder.getLocale();
|
|
|
|
|
Map map = new HashMap(3);
|
|
|
|
|
LocalDateTime localDateTime = LocalDateTime.now();
|
|
|
|
|
LocalDateTime localDateTime2 = localDateTime.plusDays(1);
|
|
|
|
|
String endTime = DateTimeUtil.dateTimeToString(localDateTime2);
|
|
|
|
|
// 当前时间减1
|
|
|
|
|
LocalDateTime localDateTime1 = localDateTime.minusDays(1);
|
|
|
|
|
String startTime = DateTimeUtil.dateTimeToString(localDateTime1);
|
|
|
|
|
// 查询近一个月各植被类型的火点数量
|
|
|
|
|
List<Map<String, Object>> maps = firePointDao.selectNumByLandType(startTime, endTime);
|
2022-05-06 17:49:37 +08:00
|
|
|
|
map.put("land", maps);
|
2021-07-20 15:07:37 +08:00
|
|
|
|
// 查询近一个月各地区火点数量
|
|
|
|
|
List<Map<String, Object>> maps1 = firePointDao.selectNumByArea(startTime, endTime);
|
2022-05-06 17:49:37 +08:00
|
|
|
|
map.put("area", maps1);
|
2021-07-20 15:07:37 +08:00
|
|
|
|
|
2022-05-06 17:49:37 +08:00
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, map, locale);
|
2021-07-20 15:07:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询近一周的火点数量
|
2022-05-06 17:49:37 +08:00
|
|
|
|
*
|
2021-07-20 15:07:37 +08:00
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-05-06 17:49:37 +08:00
|
|
|
|
@Cacheable(keyGenerator = "keyGenerator", unless = "#result == null")
|
2021-07-20 15:07:37 +08:00
|
|
|
|
@Override
|
|
|
|
|
public String selectFirePointNumWeek() {
|
|
|
|
|
// 获取区域信息
|
|
|
|
|
Locale locale = LocaleContextHolder.getLocale();
|
|
|
|
|
Map map = new HashMap(3);
|
|
|
|
|
LocalDateTime localDateTime = LocalDateTime.now();
|
|
|
|
|
LocalDateTime localDateTime2 = localDateTime.plusDays(1);
|
|
|
|
|
String endTime = DateTimeUtil.dateTimeToString(localDateTime2);
|
|
|
|
|
// 当前时间减7
|
|
|
|
|
LocalDateTime localDateTime1 = localDateTime.minusDays(7);
|
|
|
|
|
String startTime = DateTimeUtil.dateTimeToString(localDateTime1);
|
|
|
|
|
// 查询近一个月各植被类型的火点数量
|
|
|
|
|
List<Map<String, Object>> maps = firePointDao.selectNumByLandType(startTime, endTime);
|
2022-05-06 17:49:37 +08:00
|
|
|
|
map.put("land", maps);
|
2021-07-20 15:07:37 +08:00
|
|
|
|
// 查询近一个月各地区火点数量
|
|
|
|
|
List<Map<String, Object>> maps1 = firePointDao.selectNumByArea(startTime, endTime);
|
2022-05-06 17:49:37 +08:00
|
|
|
|
map.put("area", maps1);
|
2021-07-20 15:07:37 +08:00
|
|
|
|
|
2022-05-06 17:49:37 +08:00
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, map, locale);
|
2021-07-20 15:07:37 +08:00
|
|
|
|
}
|
2021-07-22 11:54:01 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询该省所有的市
|
2022-05-06 17:49:37 +08:00
|
|
|
|
*
|
2021-08-02 17:05:11 +08:00
|
|
|
|
* @param code
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<Map<String, Object>> selectCityName(String code) {
|
|
|
|
|
return cityDao.selectCityName(code);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询市包含的区县和编码
|
2022-05-06 17:49:37 +08:00
|
|
|
|
*
|
2021-08-02 17:05:11 +08:00
|
|
|
|
* @param code
|
2021-07-22 11:54:01 +08:00
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
2021-08-02 17:05:11 +08:00
|
|
|
|
public List<Map<String, Object>> selectCountyName(String code) {
|
|
|
|
|
return countyDao.selectCountyName(code);
|
2021-07-22 11:54:01 +08:00
|
|
|
|
}
|
2021-09-23 16:36:08 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 测试插入火点信息
|
2022-05-06 17:49:37 +08:00
|
|
|
|
*
|
2021-09-23 16:36:08 +08:00
|
|
|
|
* @param firePointQo
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public FirePoint insertFireTest(FirePointQo firePointQo) {
|
|
|
|
|
FirePoint firePoint = new FirePoint();
|
|
|
|
|
firePoint.setFireCode(firePointQo.getFireCode());
|
|
|
|
|
firePoint.setCountyCode(firePointQo.getCountyCode().toString());
|
|
|
|
|
firePoint.setCountyName(firePointQo.getCountyName());
|
|
|
|
|
firePoint.setSatelliteTime(DateTimeUtil.timeMillisToString(firePointQo.getSatelliteTimeTs().longValue()));
|
|
|
|
|
firePoint.setLongitude(firePointQo.getLongitude());
|
|
|
|
|
firePoint.setLatitude(firePointQo.getLatitude());
|
2022-05-06 17:49:37 +08:00
|
|
|
|
firePoint.setFirePointAddress(AddressUtils.getLocal(firePointQo.getLatitude().toString(), firePointQo.getLongitude().toString()));
|
2021-09-23 16:36:08 +08:00
|
|
|
|
firePoint.setSatelliteType(firePointQo.getSatelliteType());
|
|
|
|
|
firePoint.setLandType(firePointQo.getLandtype());
|
|
|
|
|
firePoint.setConfidence(firePointQo.getConfidence());
|
|
|
|
|
firePoint.setAddTime(DateTimeUtil.dateTimeToString(LocalDateTime.now()));
|
|
|
|
|
firePoint.setFireType("0");
|
|
|
|
|
firePoint.setFireImage(firePointQo.getFireImage());
|
|
|
|
|
firePoint.setSatelliteImage(firePointQo.getSatelliteImage());
|
|
|
|
|
log.info("-------发现新火点");
|
|
|
|
|
return fireDao.save(firePoint);
|
|
|
|
|
}
|
2021-09-24 15:19:36 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 导入全国省市区
|
2022-05-06 17:49:37 +08:00
|
|
|
|
*
|
2021-09-24 15:19:36 +08:00
|
|
|
|
* @param file
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
@Transactional(rollbackOn = Exception.class)
|
|
|
|
|
@Override
|
|
|
|
|
public void importCityExcel(MultipartFile file) throws Exception {
|
|
|
|
|
//调用封装好的工具
|
|
|
|
|
ExcelImportUtil importUtil = new ExcelImportUtil(file);
|
|
|
|
|
//调用导入的方法,获取sheet表的内容
|
|
|
|
|
List<Map<String, String>> maps = importUtil.readExcelContent();
|
|
|
|
|
//导入订单详情表
|
|
|
|
|
List<Nationwide> orderDetails = maps.stream().filter(Objects::nonNull).map(map -> {
|
|
|
|
|
Nationwide nationwide = new Nationwide();
|
|
|
|
|
nationwide.setProName(map.get("pro_name"));
|
|
|
|
|
nationwide.setProCode(map.get("pro_code"));
|
|
|
|
|
nationwide.setCityName(map.get("city_name"));
|
|
|
|
|
nationwide.setCityCode(map.get("city_code"));
|
|
|
|
|
nationwide.setCountyName(map.get("town_name"));
|
|
|
|
|
nationwide.setCountyCode(map.get("town_code"));
|
|
|
|
|
return nationwide;
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
//批量添加到订单详情
|
|
|
|
|
nationwideDao.saveAll(orderDetails);
|
|
|
|
|
}
|
2021-09-29 08:32:23 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询今日的火点信息(测试)
|
2022-05-06 17:49:37 +08:00
|
|
|
|
*
|
2021-09-29 08:32:23 +08:00
|
|
|
|
* @param countyCode
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<FirePoint> selectTodayFire(String countyCode) {
|
|
|
|
|
String addTime = DateTimeUtil.dateToString(LocalDate.now());
|
2022-05-06 17:49:37 +08:00
|
|
|
|
if ("0000".equals(countyCode.substring(2))) {
|
2021-09-29 08:32:23 +08:00
|
|
|
|
List<CityEntity> byProCode = cityDao.findByProCode(countyCode);
|
|
|
|
|
String proName = byProCode.get(0).getProName();
|
2022-05-06 17:49:37 +08:00
|
|
|
|
return fireDao.selectTodayFire(addTime, proName);
|
|
|
|
|
} else if ("00".equals(countyCode.substring(4)) && !"0000".equals(countyCode.substring(2))) {
|
2021-09-29 08:32:23 +08:00
|
|
|
|
List<CountyEntity> byCityCode = countyDao.findByCityCode(countyCode);
|
|
|
|
|
String cityName = byCityCode.get(0).getCityName();
|
2022-05-06 17:49:37 +08:00
|
|
|
|
return fireDao.selectTodayFire(addTime, cityName);
|
|
|
|
|
} else {
|
|
|
|
|
return fireDao.selectTodayFireOne(addTime, countyCode);
|
2021-09-29 08:32:23 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-07-13 10:18:08 +08:00
|
|
|
|
}
|