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;
|
2022-05-07 15:20:28 +08:00
|
|
|
|
import com.xkrs.model.vo.GaoDeIgGeocodeVo;
|
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;
|
2022-06-02 22:43:22 +08:00
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
2021-07-16 09:52:25 +08:00
|
|
|
|
import javax.transaction.Transactional;
|
2021-07-16 10:47:24 +08:00
|
|
|
|
import java.io.IOException;
|
2022-06-02 22:43:22 +08:00
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
2022-06-02 22:26:26 +08:00
|
|
|
|
import java.text.DecimalFormat;
|
2021-07-15 15:22:23 +08:00
|
|
|
|
import java.time.LocalDate;
|
2021-07-13 10:18:08 +08:00
|
|
|
|
import java.time.LocalDateTime;
|
2022-06-02 22:43:22 +08:00
|
|
|
|
import java.time.LocalTime;
|
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;
|
2022-06-02 22:43:22 +08:00
|
|
|
|
import static com.xkrs.utils.DateTimeUtil.dateTimeToString;
|
|
|
|
|
import static com.xkrs.utils.XlsxUtil.downloadXlsx;
|
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;
|
|
|
|
|
|
2022-06-02 10:06:59 +08:00
|
|
|
|
@Resource
|
|
|
|
|
private SettingDao settingDao;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private ShanDongFirePointDao shanDongFirePointDao;
|
|
|
|
|
|
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;
|
|
|
|
|
|
2022-05-07 15:31:25 +08:00
|
|
|
|
@Resource
|
|
|
|
|
private StreetDao streetDao;
|
|
|
|
|
|
2021-09-24 15:19:36 +08:00
|
|
|
|
@Resource
|
|
|
|
|
private NationwideDao nationwideDao;
|
|
|
|
|
|
2022-06-02 17:15:31 +08:00
|
|
|
|
@Resource
|
|
|
|
|
private CountyCodeWeiXinDao countyCodeWeiXinDao;
|
|
|
|
|
|
2022-06-03 18:52:10 +08:00
|
|
|
|
@Resource
|
|
|
|
|
private RelRoleAuthorityDao relRoleAuthorityDao;
|
|
|
|
|
|
2022-06-07 16:24:00 +08:00
|
|
|
|
@Resource
|
|
|
|
|
private FirePointQueryHelper firePointQueryHelper;
|
|
|
|
|
|
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) {
|
2022-05-06 17:49:37 +08:00
|
|
|
|
if (firePointQo.getLandtype().equals("水体")) {
|
2021-10-11 16:28:03 +08:00
|
|
|
|
return null;
|
2022-06-02 10:06:59 +08:00
|
|
|
|
}
|
|
|
|
|
if ("Himawari 8".equals(firePointQo.getSatelliteType()) && "L".equals(firePointQo.getConfidence())) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
if ("Himawari 8".equals(firePointQo.getSatelliteType()) && "N".equals(firePointQo.getConfidence())) {
|
2021-12-01 14:13:05 +08:00
|
|
|
|
return null;
|
2022-06-02 10:06:59 +08:00
|
|
|
|
}
|
|
|
|
|
FirePointEntity firePointEntity = new FirePointEntity();
|
|
|
|
|
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());
|
|
|
|
|
firePointEntity.setFirePointAddress(AddressUtils.getLocal(firePointQo.getLatitude().toString(), firePointQo.getLongitude().toString()));
|
|
|
|
|
firePointEntity.setSatelliteType(firePointQo.getSatelliteType());
|
|
|
|
|
firePointEntity.setLandType(firePointQo.getLandtype());
|
|
|
|
|
firePointEntity.setConfidence(firePointQo.getConfidence());
|
2022-06-02 22:43:22 +08:00
|
|
|
|
firePointEntity.setAddTime(dateTimeToString(LocalDateTime.now()));
|
2022-06-02 10:06:59 +08:00
|
|
|
|
firePointEntity.setFireType("0");
|
|
|
|
|
firePointEntity.setFireImage(firePointQo.getFireImage());
|
|
|
|
|
firePointEntity.setSatelliteImage(firePointQo.getSatelliteImage());
|
2022-06-02 10:53:48 +08:00
|
|
|
|
firePointEntity.setAuditFireType("0");//初始化火点为未审核状态
|
2022-06-02 10:06:59 +08:00
|
|
|
|
try {
|
|
|
|
|
bindStreetCodeName(firePointEntity);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
System.out.println("添加火点信息 逆地理编码请求街道编号失败:" + e.getMessage());
|
|
|
|
|
}
|
2022-06-07 11:21:13 +08:00
|
|
|
|
if (firePointEntity.getCountyCode().startsWith("37")) {
|
2022-06-02 15:10:47 +08:00
|
|
|
|
return null;
|
2022-06-02 10:06:59 +08:00
|
|
|
|
}
|
|
|
|
|
FirePointEntity existFireCode = firePointDao.findByFireCode(firePointEntity.getFireCode());
|
|
|
|
|
if (existFireCode != null) {
|
2021-12-01 14:13:05 +08:00
|
|
|
|
return null;
|
2021-10-11 16:28:03 +08:00
|
|
|
|
}
|
2022-06-02 10:06:59 +08:00
|
|
|
|
log.info("-------发现新火点");
|
2022-06-07 11:21:13 +08:00
|
|
|
|
return firePointDao.save(firePointEntity);
|
2021-07-13 10:18:08 +08:00
|
|
|
|
}
|
2021-07-15 15:22:23 +08:00
|
|
|
|
|
2022-06-02 15:10:47 +08:00
|
|
|
|
/**
|
|
|
|
|
* 添加火点信息
|
|
|
|
|
*
|
|
|
|
|
* @param firePointQo
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@CacheEvict(value = "FirePointServiceCache", allEntries = true)
|
|
|
|
|
@Override
|
|
|
|
|
public ShanDongFirePointEntity insertFirePointChannelTwo(FirePointQo firePointQo) {
|
|
|
|
|
if (firePointQo.getLandtype().equals("水体")) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
if ("Himawari 8".equals(firePointQo.getSatelliteType()) && "L".equals(firePointQo.getConfidence())) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
if ("Himawari 8".equals(firePointQo.getSatelliteType()) && "N".equals(firePointQo.getConfidence())) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2022-06-07 11:21:13 +08:00
|
|
|
|
ShanDongFirePointEntity shanDongFirePoint = new ShanDongFirePointEntity();
|
|
|
|
|
shanDongFirePoint.setFireCode(firePointQo.getFireCode());
|
|
|
|
|
shanDongFirePoint.setCountyCode(firePointQo.getCountyCode().toString());
|
|
|
|
|
shanDongFirePoint.setCountyName(firePointQo.getCountyName());
|
|
|
|
|
shanDongFirePoint.setSatelliteTime(DateTimeUtil.timeMillisToString(firePointQo.getSatelliteTimeTs().longValue()));
|
|
|
|
|
shanDongFirePoint.setLongitude(firePointQo.getLongitude());
|
|
|
|
|
shanDongFirePoint.setLatitude(firePointQo.getLatitude());
|
|
|
|
|
shanDongFirePoint.setFirePointAddress(AddressUtils.getLocal(firePointQo.getLatitude().toString(), firePointQo.getLongitude().toString()));
|
|
|
|
|
shanDongFirePoint.setSatelliteType(firePointQo.getSatelliteType());
|
|
|
|
|
shanDongFirePoint.setLandType(firePointQo.getLandtype());
|
|
|
|
|
shanDongFirePoint.setConfidence(firePointQo.getConfidence());
|
|
|
|
|
shanDongFirePoint.setAddTime(dateTimeToString(LocalDateTime.now()));
|
|
|
|
|
shanDongFirePoint.setFireType("0");
|
|
|
|
|
shanDongFirePoint.setFireImage(firePointQo.getFireImage());
|
|
|
|
|
shanDongFirePoint.setSatelliteImage(firePointQo.getSatelliteImage());
|
|
|
|
|
shanDongFirePoint.setVerifyState("0");
|
2022-06-02 15:10:47 +08:00
|
|
|
|
try {
|
2022-06-07 11:21:13 +08:00
|
|
|
|
bindStreetCodeName(shanDongFirePoint);
|
2022-06-02 15:10:47 +08:00
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
System.out.println("添加山东火点信息 逆地理编码请求街道编号失败:" + e.getMessage());
|
|
|
|
|
}
|
2022-06-07 11:21:13 +08:00
|
|
|
|
//如果是山东的点,就入库
|
|
|
|
|
if (shanDongFirePoint.getCountyCode().startsWith("37")) {
|
|
|
|
|
if (isSwitchStateOpen()) {
|
|
|
|
|
//如果开关已打开,就只将未审核的火点添加到山东临时表
|
|
|
|
|
if (shanDongFirePointDao.findByFireCode(shanDongFirePoint.getFireCode()) != null) {
|
|
|
|
|
//山东临时表已经有编号相同的火点存在,返回添加失败
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
log.info("-------发现新山东火点");
|
|
|
|
|
ShanDongFirePointEntity savedShanDongFirePoint = shanDongFirePointDao.save(shanDongFirePoint);
|
|
|
|
|
try {//微信消息通知火点审核工作组
|
|
|
|
|
String messageContent = getMessageContent(savedShanDongFirePoint);
|
|
|
|
|
WDWxSendMsgUtil.sendMsg("18447024917@chatroom", messageContent, 0);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
return savedShanDongFirePoint;
|
|
|
|
|
} else {
|
|
|
|
|
//如果开关已关闭,就将火点添加到山东临时表,同时自动审核通过添加到全国火点表
|
|
|
|
|
if (shanDongFirePointDao.findByFireCode(shanDongFirePoint.getFireCode()) != null) {
|
|
|
|
|
//山东临时表已经有编号相同的火点存在,返回添加失败
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
if (firePointDao.findByFireCode(shanDongFirePoint.getFireCode()) != null) {
|
|
|
|
|
//全国火点表已经有编号相同的火点存在,返回添加失败
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
log.info("-------发现新火点");
|
|
|
|
|
shanDongFirePoint.setVerifyState("1");
|
|
|
|
|
ShanDongFirePointEntity savedShanDongFirePoint = shanDongFirePointDao.save(shanDongFirePoint);
|
|
|
|
|
|
|
|
|
|
FirePointEntity firePoint = getFirePointByShanDongFirePoint(shanDongFirePoint);
|
|
|
|
|
log.info("-------转存新火点");
|
|
|
|
|
firePointDao.save(firePoint);
|
|
|
|
|
//发送消息通知
|
|
|
|
|
sendBroadcast(firePoint);
|
|
|
|
|
return savedShanDongFirePoint;
|
2022-06-02 17:15:31 +08:00
|
|
|
|
}
|
2022-06-02 15:10:47 +08:00
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-07 11:21:13 +08:00
|
|
|
|
/**
|
|
|
|
|
* 根据山东火点生成全国火点
|
|
|
|
|
*/
|
|
|
|
|
private FirePointEntity getFirePointByShanDongFirePoint(ShanDongFirePointEntity shanDongFirePoint) {
|
|
|
|
|
FirePointEntity firePoint = new FirePointEntity();
|
|
|
|
|
firePoint.setFireCode(shanDongFirePoint.getFireCode());
|
|
|
|
|
firePoint.setCountyCode(shanDongFirePoint.getCountyCode());
|
|
|
|
|
firePoint.setCountyName(shanDongFirePoint.getCountyName());
|
|
|
|
|
firePoint.setSatelliteTime(shanDongFirePoint.getSatelliteTime());
|
|
|
|
|
firePoint.setLongitude(shanDongFirePoint.getLongitude());
|
|
|
|
|
firePoint.setLatitude(shanDongFirePoint.getLatitude());
|
|
|
|
|
firePoint.setFirePointAddress(shanDongFirePoint.getFirePointAddress());
|
|
|
|
|
firePoint.setSatelliteType(shanDongFirePoint.getSatelliteType());
|
|
|
|
|
firePoint.setLandType(shanDongFirePoint.getLandType());
|
|
|
|
|
firePoint.setConfidence(shanDongFirePoint.getConfidence());
|
|
|
|
|
firePoint.setAddTime(shanDongFirePoint.getAddTime());
|
|
|
|
|
firePoint.setFireType(shanDongFirePoint.getFireType());
|
|
|
|
|
firePoint.setFireImage(shanDongFirePoint.getFireImage());
|
|
|
|
|
firePoint.setSatelliteImage(shanDongFirePoint.getSatelliteImage());
|
|
|
|
|
firePoint.setStreetCode(shanDongFirePoint.getStreetCode());
|
|
|
|
|
firePoint.setStreetName(shanDongFirePoint.getStreetName());
|
|
|
|
|
firePoint.setAuditFireType("0");//初始化火点为未审核状态
|
|
|
|
|
return firePoint;
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-02 10:06:59 +08:00
|
|
|
|
/**
|
|
|
|
|
* 返回开关是否为打开状态
|
|
|
|
|
*
|
|
|
|
|
* @return true:已打开,false:已关闭
|
|
|
|
|
*/
|
|
|
|
|
private boolean isSwitchStateOpen() {
|
|
|
|
|
List<SettingEntity> settingEntityList = settingDao.findAll();
|
|
|
|
|
if (settingEntityList.isEmpty()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
SettingEntity settingEntity = settingEntityList.get(0);
|
|
|
|
|
return "1".equals(settingEntity.getSwitchState());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2022-06-02 15:10:47 +08:00
|
|
|
|
* 为实体类设置街道编号和街道名称
|
2022-06-02 10:06:59 +08:00
|
|
|
|
*/
|
2022-06-02 15:10:47 +08:00
|
|
|
|
private void bindStreetCodeName(FirePointEntity firePointEntity) throws Exception {
|
|
|
|
|
List<String> locationList = new ArrayList<>();
|
|
|
|
|
locationList.add(firePointEntity.getLongitude() + "," + firePointEntity.getLatitude());
|
|
|
|
|
GaoDeIgGeocodeVo geocode = GaoDeApiUtil.geocode(locationList);
|
|
|
|
|
String townCode = geocode.getRegeocodes().get(0).getAddressComponent().get(0).getTowncode();
|
|
|
|
|
if (townCode.length() > 9) {
|
|
|
|
|
townCode = townCode.substring(0, 9);
|
|
|
|
|
}
|
|
|
|
|
firePointEntity.setStreetCode(townCode);
|
|
|
|
|
List<StreetEntity> byStreetCode = streetDao.findByStreetCode(townCode);
|
|
|
|
|
if (byStreetCode != null && byStreetCode.size() > 0) {
|
|
|
|
|
firePointEntity.setStreetName(byStreetCode.get(0).getStreetName());
|
2022-06-02 10:06:59 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 为实体类设置街道编号和街道名称
|
|
|
|
|
*/
|
2022-06-02 15:10:47 +08:00
|
|
|
|
private void bindStreetCodeName(ShanDongFirePointEntity firePointEntity) throws Exception {
|
2022-05-07 15:20:28 +08:00
|
|
|
|
List<String> locationList = new ArrayList<>();
|
|
|
|
|
locationList.add(firePointEntity.getLongitude() + "," + firePointEntity.getLatitude());
|
|
|
|
|
GaoDeIgGeocodeVo geocode = GaoDeApiUtil.geocode(locationList);
|
|
|
|
|
String townCode = geocode.getRegeocodes().get(0).getAddressComponent().get(0).getTowncode();
|
|
|
|
|
if (townCode.length() > 9) {
|
|
|
|
|
townCode = townCode.substring(0, 9);
|
|
|
|
|
}
|
|
|
|
|
firePointEntity.setStreetCode(townCode);
|
2022-05-26 18:20:14 +08:00
|
|
|
|
List<StreetEntity> byStreetCode = streetDao.findByStreetCode(townCode);
|
|
|
|
|
if (byStreetCode != null && byStreetCode.size() > 0) {
|
|
|
|
|
firePointEntity.setStreetName(byStreetCode.get(0).getStreetName());
|
|
|
|
|
}
|
2022-05-07 15:20:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-06-02 11:38:55 +08:00
|
|
|
|
/**
|
|
|
|
|
* 根据火点编号更新审核状态
|
|
|
|
|
* 操作1:将火点编号对应的火点从山东火点表转存到火点表
|
|
|
|
|
* 操作2:将山东火点表中的这个火点的审核状态更新
|
|
|
|
|
*/
|
|
|
|
|
@Transactional(rollbackOn = Exception.class)
|
|
|
|
|
@Override
|
|
|
|
|
public String updateVerifyStateByFireCode(String fireCode, String verifyState) {
|
|
|
|
|
// 获取区域信息
|
|
|
|
|
Locale locale = LocaleContextHolder.getLocale();
|
2022-06-07 11:21:13 +08:00
|
|
|
|
if ((!"0".equals(verifyState)) && (!"1".equals(verifyState)) && (!"2".equals(verifyState))) {
|
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL, "审核失败,审核状态参数错误", locale);
|
|
|
|
|
}
|
2022-06-02 11:38:55 +08:00
|
|
|
|
ShanDongFirePointEntity existShanDongFirePoint = shanDongFirePointDao.findByFireCode(fireCode);
|
|
|
|
|
//山东火点表找不到这个火点,返回失败
|
|
|
|
|
if (existShanDongFirePoint == null) {
|
2022-06-07 11:21:13 +08:00
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "审核失败,没有指定的火点编号", locale);
|
2022-06-02 11:38:55 +08:00
|
|
|
|
}
|
2022-06-07 11:21:13 +08:00
|
|
|
|
if ("0".equals(existShanDongFirePoint.getVerifyState())) {
|
|
|
|
|
if ("0".equals(verifyState)) {
|
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "审核失败,审核状态不能被设置为未审核", locale);
|
2022-06-02 11:38:55 +08:00
|
|
|
|
}
|
2022-06-07 11:21:13 +08:00
|
|
|
|
if ("1".equals(verifyState)) {
|
|
|
|
|
//火点表能找到这个火点,返回失败
|
|
|
|
|
FirePointEntity existFirePoint = firePointDao.findByFireCode(fireCode);
|
|
|
|
|
if (existFirePoint != null) {
|
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "修改失败,火点库已存在指定的火点编号", locale);
|
|
|
|
|
}
|
|
|
|
|
//操作1:将火点编号对应的火点从山东火点表转存到火点表
|
|
|
|
|
FirePointEntity firePoint = getFirePointByShanDongFirePoint(existShanDongFirePoint);
|
|
|
|
|
log.info("-------转存新火点");
|
|
|
|
|
firePointDao.save(firePoint);
|
|
|
|
|
//发送消息通知
|
|
|
|
|
sendBroadcast(firePoint);
|
2022-06-02 17:15:31 +08:00
|
|
|
|
}
|
2022-06-07 11:21:13 +08:00
|
|
|
|
//操作2:将山东火点表中的这个火点的审核状态更新
|
|
|
|
|
shanDongFirePointDao.updateVerifyStateByFireCode(fireCode, verifyState);
|
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale);
|
2022-06-02 11:38:55 +08:00
|
|
|
|
}
|
2022-06-07 11:21:13 +08:00
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "审核失败,火点不能被重复审核", locale);
|
2022-06-02 11:38:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-06-02 22:10:17 +08:00
|
|
|
|
private void sendBroadcast(FirePointEntity firePointEntity) {
|
2022-06-02 17:15:31 +08:00
|
|
|
|
//发送微信消息
|
2022-06-02 22:10:17 +08:00
|
|
|
|
sendWeiXinMessage(firePointEntity);
|
2022-06-02 17:15:31 +08:00
|
|
|
|
//发送短信消息
|
2022-06-02 22:10:17 +08:00
|
|
|
|
sendSMSMessage(firePointEntity);
|
2022-06-02 17:15:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 发送微信消息
|
|
|
|
|
*
|
2022-06-02 22:10:17 +08:00
|
|
|
|
* @param firePointEntity
|
2022-06-02 17:15:31 +08:00
|
|
|
|
*/
|
2022-06-02 22:10:17 +08:00
|
|
|
|
private void sendWeiXinMessage(FirePointEntity firePointEntity) {
|
2022-06-02 17:15:31 +08:00
|
|
|
|
List<CountyCodeWeiXinEntity> countyCodeWeiXinList = countyCodeWeiXinDao.findAll();
|
|
|
|
|
if (countyCodeWeiXinList.isEmpty()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
List<String> weixinIdList = new ArrayList<>();
|
|
|
|
|
for (CountyCodeWeiXinEntity countyCodeWeiXin : countyCodeWeiXinList) {
|
|
|
|
|
String countyCode = countyCodeWeiXin.getCountyCode();
|
|
|
|
|
String startCountyCode = getStartCountyCode(countyCode);
|
2022-06-02 22:10:17 +08:00
|
|
|
|
if (firePointEntity.getStreetCode().startsWith(startCountyCode)) {
|
2022-06-02 17:15:31 +08:00
|
|
|
|
weixinIdList.add(countyCodeWeiXin.getWeixinId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (weixinIdList.size() > 0) {
|
2022-06-03 15:21:57 +08:00
|
|
|
|
String messageContent = getMessageContent(firePointEntity);
|
2022-06-02 17:15:31 +08:00
|
|
|
|
for (String weixinId : weixinIdList) {
|
|
|
|
|
try {
|
2022-06-03 15:21:57 +08:00
|
|
|
|
WDWxSendMsgUtil.sendMsg(weixinId, messageContent, 0);
|
2022-06-02 17:15:31 +08:00
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-03 15:21:57 +08:00
|
|
|
|
private String getMessageContent(FirePointEntity firePointEntity) {
|
|
|
|
|
java.text.DecimalFormat decimalFormat = new DecimalFormat("#.000000");
|
|
|
|
|
String satelliteTime = firePointEntity.getSatelliteTime();
|
|
|
|
|
String formatLongitude = decimalFormat.format(firePointEntity.getLongitude());
|
|
|
|
|
String formatLatitude = decimalFormat.format(firePointEntity.getLatitude());
|
|
|
|
|
String countyName = firePointEntity.getCountyName();
|
2022-06-06 17:43:31 +08:00
|
|
|
|
String streetName = firePointEntity.getStreetName();
|
|
|
|
|
String content = firePointEntity.getSatelliteType() + "发现1个火点。\n卫星时间:" + satelliteTime + ";\nlongitude:" + formatLongitude + ";\nlatitude:" + formatLatitude + ";\ncountyName:" + countyName + ";\nstreetName:" + streetName;
|
2022-06-03 15:21:57 +08:00
|
|
|
|
return content;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String getMessageContent(ShanDongFirePointEntity firePointEntity) {
|
|
|
|
|
java.text.DecimalFormat decimalFormat = new DecimalFormat("#.000000");
|
|
|
|
|
String satelliteTime = firePointEntity.getSatelliteTime();
|
|
|
|
|
String formatLongitude = decimalFormat.format(firePointEntity.getLongitude());
|
|
|
|
|
String formatLatitude = decimalFormat.format(firePointEntity.getLatitude());
|
|
|
|
|
String countyName = firePointEntity.getCountyName();
|
2022-06-06 17:43:31 +08:00
|
|
|
|
String streetName = firePointEntity.getStreetName();
|
|
|
|
|
String content = firePointEntity.getSatelliteType() + "发现1个待审核火点。\n卫星时间:" + satelliteTime + ";\nlongitude:" + formatLongitude + ";\nlatitude:" + formatLatitude + ";\ncountyName:" + countyName + ";\nstreetName:" + streetName;
|
2022-06-03 15:21:57 +08:00
|
|
|
|
return content;
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-02 17:15:31 +08:00
|
|
|
|
/**
|
|
|
|
|
* 发送短信消息
|
|
|
|
|
*
|
2022-06-02 22:10:17 +08:00
|
|
|
|
* @param firePointEntity
|
2022-06-02 17:15:31 +08:00
|
|
|
|
*/
|
2022-06-02 22:10:17 +08:00
|
|
|
|
private void sendSMSMessage(FirePointEntity firePointEntity) {
|
2022-06-02 17:15:31 +08:00
|
|
|
|
List<SysUserEntity> sysUserList = sysUserDao.findAll();
|
|
|
|
|
if (sysUserList.isEmpty()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-06-03 18:52:10 +08:00
|
|
|
|
List<RelRoleAuthorityEntity> administratorList = relRoleAuthorityDao.selectByAuthorityId(1);
|
2022-06-02 17:15:31 +08:00
|
|
|
|
List<String> telephoneList = new ArrayList<>();
|
|
|
|
|
for (SysUserEntity sysUser : sysUserList) {
|
2022-06-02 22:10:17 +08:00
|
|
|
|
try {
|
|
|
|
|
String countyCode = sysUser.getCountyCode();
|
|
|
|
|
String startCountyCode = getStartCountyCode(countyCode);
|
|
|
|
|
if (firePointEntity.getStreetCode().startsWith(startCountyCode)) {
|
2022-06-03 18:52:10 +08:00
|
|
|
|
if (sysUser.getDeleteFlag() != 0) {//被删除的用户不发短信
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (sysUser.getActiveFlag() != 0) {//被禁用的用户不发短信
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (sysUser.getReceiveSms() != 1) {//关掉开关的用户不发短信
|
2022-06-02 22:10:17 +08:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
LocalDateTime sysUserOverDateTime = DateTimeUtil.stringToDateTimeFormatter(sysUser.getOverTime(), DateTimeUtil.COMMON_FORMATTER_DATETIME);
|
2022-06-03 18:52:10 +08:00
|
|
|
|
if (sysUserOverDateTime.isBefore(DateTimeUtil.getNowTime())) {//过期用户不发短信
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (isAdministrator(administratorList, sysUser)) {//管理员用户不发短信
|
2022-06-02 22:10:17 +08:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
telephoneList.add("86" + sysUser.getUserName());
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
continue;
|
2022-06-02 17:15:31 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (telephoneList.size() > 0) {
|
2022-06-02 22:10:17 +08:00
|
|
|
|
String[] telephoneArray = telephoneList.toArray(new String[]{});
|
|
|
|
|
SendSms.sendSmsToUser(telephoneArray, "1425995", new String[]{firePointEntity.getFirePointAddress()});
|
2022-06-02 17:15:31 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-03 18:52:10 +08:00
|
|
|
|
/**
|
|
|
|
|
* 判断是否是管理员
|
|
|
|
|
*/
|
|
|
|
|
private boolean isAdministrator(List<RelRoleAuthorityEntity> administratorList, SysUserEntity sysUser) {
|
|
|
|
|
if (administratorList == null || administratorList.size() == 0) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
for (RelRoleAuthorityEntity administrator : administratorList) {
|
2022-06-04 11:12:48 +08:00
|
|
|
|
if (administrator.getUserId().intValue() == sysUser.getId().intValue()) {
|
2022-06-03 18:52:10 +08:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-02 17:15:31 +08:00
|
|
|
|
private String getStartCountyCode(String countyCode) {
|
|
|
|
|
try {
|
|
|
|
|
String temp = countyCode;
|
|
|
|
|
while (temp.endsWith("0")) {
|
|
|
|
|
temp = temp.substring(0, temp.length() - 1);
|
|
|
|
|
}
|
|
|
|
|
return temp;
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-02 22:43:22 +08:00
|
|
|
|
@Override
|
|
|
|
|
public String downloadVipUserFilePoint(HttpServletRequest request, HttpServletResponse response) {
|
|
|
|
|
LocalDate now = LocalDate.now();
|
|
|
|
|
List<Map<String, String>> list = firePointDao.downloadFirePointByVip(dateTimeToString(LocalDateTime.of(now.minusDays(1), LocalTime.MIN)));
|
|
|
|
|
if (list.size() == 0) {
|
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "无数据!", LocaleContextHolder.getLocale());
|
|
|
|
|
}
|
|
|
|
|
int year = now.getYear();
|
|
|
|
|
int month = now.getMonth().getValue();
|
|
|
|
|
int day = now.getDayOfMonth();
|
|
|
|
|
String fileName = String.format("%s_%s_%s_VIP用户火点信息列表.xlsx", year, month, day);
|
|
|
|
|
response.setContentType("application/octet-stream; charset=UTF8");
|
|
|
|
|
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(fileName, StandardCharsets.UTF_8));
|
|
|
|
|
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
|
|
|
|
|
try {
|
|
|
|
|
downloadXlsx(list, response.getOutputStream());
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
log.error("download vip user's fire point fail: {}", e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "ok", LocaleContextHolder.getLocale());
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-15 15:22:23 +08:00
|
|
|
|
/**
|
|
|
|
|
* 查询今天的火点信息
|
|
|
|
|
*/
|
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-07 15:31:25 +08:00
|
|
|
|
if (9 == countyCode.length()) {
|
2022-05-07 16:36:04 +08:00
|
|
|
|
return firePointDao.selectTodayFirePointOneStreet(addTime, countyCode);
|
2022-05-07 15:31:25 +08:00
|
|
|
|
} else 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 firePointDao.selectTodayFirePoint(addTime, proName);
|
|
|
|
|
} 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();
|
2022-05-06 17:49:37 +08:00
|
|
|
|
return firePointDao.selectTodayFirePoint(addTime, cityName);
|
|
|
|
|
} else {
|
|
|
|
|
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-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);
|
2022-06-02 22:43:22 +08:00
|
|
|
|
String time = dateTimeToString(LocalDateTime.now());
|
2021-07-16 09:52:25 +08:00
|
|
|
|
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);
|
2022-06-02 22:43:22 +08:00
|
|
|
|
String time = dateTimeToString(LocalDateTime.now());
|
2021-07-16 09:52:25 +08:00
|
|
|
|
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
|
|
|
|
}
|
2022-06-02 22:43:22 +08:00
|
|
|
|
String s = dateTimeToString(LocalDateTime.now());
|
2021-07-16 10:47:24 +08:00
|
|
|
|
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();
|
2022-06-02 22:43:22 +08:00
|
|
|
|
String endTime = dateTimeToString(localDateTime);
|
2021-07-16 17:21:31 +08:00
|
|
|
|
// 当前时间减7
|
|
|
|
|
LocalDateTime localDateTime1 = localDateTime.minusDays(7);
|
2022-06-02 22:43:22 +08:00
|
|
|
|
String startTime = dateTimeToString(localDateTime1);
|
2021-07-16 17:21:31 +08:00
|
|
|
|
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();
|
2022-06-02 22:43:22 +08:00
|
|
|
|
String endTime = dateTimeToString(localDateTime);
|
2021-12-07 08:32:55 +08:00
|
|
|
|
// 当前时间减31
|
2021-08-05 15:53:42 +08:00
|
|
|
|
LocalDateTime localDateTime1 = localDateTime.minusDays(31);
|
2022-06-02 22:43:22 +08:00
|
|
|
|
String startTime = dateTimeToString(localDateTime1);
|
2022-05-07 16:00:58 +08:00
|
|
|
|
if (9 == countyCode.length()) {
|
2022-05-07 16:36:04 +08:00
|
|
|
|
return query.selectFirePointByMonthStreet(countyCode, startTime, endTime);
|
2022-05-07 16:00:58 +08:00
|
|
|
|
} else 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-07 16:00:58 +08:00
|
|
|
|
return query.selectFirePointByMonthPro(proName, startTime, endTime);
|
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();
|
2022-05-07 16:00:58 +08:00
|
|
|
|
return query.selectFirePointByMonthCity(cityName, startTime, endTime);
|
2022-05-06 17:49:37 +08:00
|
|
|
|
} else {
|
2022-05-07 16:00:58 +08:00
|
|
|
|
return query.selectFirePointByMonthCounty(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);
|
2022-06-02 22:43:22 +08:00
|
|
|
|
String endTime = dateTimeToString(localDateTime2);
|
2021-07-20 15:07:37 +08:00
|
|
|
|
// 当前时间减30
|
|
|
|
|
LocalDateTime localDateTime1 = localDateTime.minusDays(30);
|
2022-06-02 22:43:22 +08:00
|
|
|
|
String startTime = dateTimeToString(localDateTime1);
|
2021-07-20 15:07:37 +08:00
|
|
|
|
// 查询近一个月各植被类型的火点数量
|
|
|
|
|
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);
|
2022-06-02 22:43:22 +08:00
|
|
|
|
String endTime = dateTimeToString(localDateTime2);
|
2021-07-20 15:07:37 +08:00
|
|
|
|
// 当前时间减1
|
|
|
|
|
LocalDateTime localDateTime1 = localDateTime.minusDays(1);
|
2022-06-02 22:43:22 +08:00
|
|
|
|
String startTime = dateTimeToString(localDateTime1);
|
2021-07-20 15:07:37 +08:00
|
|
|
|
// 查询近一个月各植被类型的火点数量
|
|
|
|
|
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);
|
2022-06-02 22:43:22 +08:00
|
|
|
|
String endTime = dateTimeToString(localDateTime2);
|
2021-07-20 15:07:37 +08:00
|
|
|
|
// 当前时间减7
|
|
|
|
|
LocalDateTime localDateTime1 = localDateTime.minusDays(7);
|
2022-06-02 22:43:22 +08:00
|
|
|
|
String startTime = dateTimeToString(localDateTime1);
|
2021-07-20 15:07:37 +08:00
|
|
|
|
// 查询近一个月各植被类型的火点数量
|
|
|
|
|
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
|
|
|
|
|
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-07 17:45:40 +08:00
|
|
|
|
/**
|
|
|
|
|
* 更新火点的街道编号数据
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public String updateFirePointStreetCode() {
|
|
|
|
|
System.out.println("开始格式化街道编号");
|
2022-05-09 10:17:57 +08:00
|
|
|
|
List<FirePointEntity> firePointEntityList = firePointDao.selectAbnormalStreetCode();
|
2022-05-07 17:45:40 +08:00
|
|
|
|
long startTimeMillis = System.currentTimeMillis();
|
|
|
|
|
int listSize = firePointEntityList.size();
|
|
|
|
|
for (int i = 0; i < listSize; i++) {
|
|
|
|
|
try {
|
|
|
|
|
FirePointEntity firePointEntity = firePointEntityList.get(i);
|
|
|
|
|
List<String> locationList = new ArrayList<>();
|
|
|
|
|
locationList.add(firePointEntity.getLongitude() + "," + firePointEntity.getLatitude());
|
|
|
|
|
GaoDeIgGeocodeVo geocode = GaoDeApiUtil.geocode(locationList);
|
|
|
|
|
String townCode = geocode.getRegeocodes().get(0).getAddressComponent().get(0).getTowncode();
|
|
|
|
|
if (townCode.length() > 9) {
|
|
|
|
|
townCode = townCode.substring(0, 9);
|
|
|
|
|
}
|
|
|
|
|
firePointDao.updateStreetCodeById(firePointEntity.getId(), townCode);
|
|
|
|
|
if (i % 10 == 0) {
|
|
|
|
|
long spendTimeMillis = System.currentTimeMillis() - startTimeMillis;
|
|
|
|
|
double remainTimeMillis = (listSize - i) * spendTimeMillis * 1D / i;
|
|
|
|
|
System.out.println("已完成(" + i + "/" + listSize + "),用时" + formatDuring(spendTimeMillis) + ",剩余" + formatDuring((long) remainTimeMillis));
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
System.out.println("街道编号格式化出现错误:" + e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Locale locale = LocaleContextHolder.getLocale();
|
|
|
|
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "街道编号格式化完毕", locale);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String formatDuring(long mss) {
|
|
|
|
|
long days = mss / (1000 * 60 * 60 * 24);
|
|
|
|
|
long hours = (mss % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60);
|
|
|
|
|
long minutes = (mss % (1000 * 60 * 60)) / (1000 * 60);
|
|
|
|
|
long seconds = (mss % (1000 * 60)) / 1000;
|
|
|
|
|
if (days <= 0 && hours <= 0 && minutes <= 0) {
|
|
|
|
|
return seconds + " 秒 ";
|
|
|
|
|
}
|
|
|
|
|
if (days <= 0 && hours <= 0) {
|
|
|
|
|
return minutes + " 分钟 " + seconds + " 秒 ";
|
|
|
|
|
}
|
|
|
|
|
if (days <= 0) {
|
|
|
|
|
return hours + " 小时 " + minutes + " 分钟 " + seconds + " 秒 ";
|
|
|
|
|
}
|
|
|
|
|
return days + " 天 " + hours + " 小时 " + minutes + " 分钟 " + seconds + " 秒 ";
|
|
|
|
|
}
|
2021-07-13 10:18:08 +08:00
|
|
|
|
}
|