539 lines
26 KiB
Java
539 lines
26 KiB
Java
package com.xkrs.service.impl;
|
||
|
||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||
import com.xkrs.common.encapsulation.PromptMessageEnum;
|
||
import com.xkrs.dao.*;
|
||
import com.xkrs.model.entity.CountyCodeWeiXinEntity;
|
||
import com.xkrs.model.entity.FirePointEntity;
|
||
import com.xkrs.model.entity.ShanDongFirePointEntity;
|
||
import com.xkrs.model.qo.FirePointQo;
|
||
import com.xkrs.model.vo.GaoDeIgGeocodeVo;
|
||
import com.xkrs.service.FirePointService;
|
||
import com.xkrs.service.GlobalConfigService;
|
||
import com.xkrs.service.StreetService;
|
||
import com.xkrs.sms.PushHelper;
|
||
import com.xkrs.sms.SMSHelper;
|
||
import com.xkrs.utils.*;
|
||
import org.slf4j.Logger;
|
||
import org.slf4j.LoggerFactory;
|
||
import org.springframework.cache.annotation.CacheConfig;
|
||
import org.springframework.cache.annotation.CacheEvict;
|
||
import org.springframework.context.i18n.LocaleContextHolder;
|
||
import org.springframework.stereotype.Service;
|
||
|
||
import javax.annotation.Resource;
|
||
import javax.servlet.http.HttpServletRequest;
|
||
import javax.servlet.http.HttpServletResponse;
|
||
import javax.transaction.Transactional;
|
||
import java.io.IOException;
|
||
import java.net.URLEncoder;
|
||
import java.nio.charset.StandardCharsets;
|
||
import java.text.DecimalFormat;
|
||
import java.time.LocalDate;
|
||
import java.time.LocalDateTime;
|
||
import java.time.LocalTime;
|
||
import java.util.*;
|
||
|
||
import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
|
||
import static com.xkrs.utils.DateTimeUtil.dateTimeToString;
|
||
import static com.xkrs.utils.XlsxUtil.downloadXlsx;
|
||
|
||
/**
|
||
* @author XinYi Song
|
||
*/
|
||
@CacheConfig(cacheNames = "FirePointServiceCache")
|
||
@Service
|
||
public class FirePointServiceImpl implements FirePointService {
|
||
|
||
public static Logger log = LoggerFactory.getLogger(FirePointServiceImpl.class);
|
||
|
||
private final Locale locale = LocaleContextHolder.getLocale();
|
||
|
||
@Resource
|
||
private FirePointDao firePointDao;
|
||
|
||
@Resource
|
||
private SettingDao settingDao;
|
||
|
||
@Resource
|
||
private ShanDongFirePointDao shanDongFirePointDao;
|
||
|
||
@Resource
|
||
private SysUserDao sysUserDao;
|
||
|
||
@Resource
|
||
private StreetDao streetDao;
|
||
|
||
@Resource
|
||
private CountyCodeWeiXinDao countyCodeWeiXinDao;
|
||
|
||
@Resource
|
||
private FirePointQueryHelper firePointQueryHelper;
|
||
|
||
@Resource
|
||
private GlobalConfigService globalConfigService;
|
||
|
||
@Resource
|
||
private StreetService streetService;
|
||
|
||
@Resource
|
||
private AgentOrgDao agentOrgDao;
|
||
|
||
@Resource
|
||
private SMSHelper smsHelper;
|
||
|
||
@Resource
|
||
private PushHelper pushHelper;
|
||
|
||
/**
|
||
* 添加火点信息
|
||
*/
|
||
@CacheEvict(value = "FirePointServiceCache", allEntries = true)
|
||
@Override
|
||
public boolean insertFirePoint(FirePointQo firePointQo) {
|
||
if ("水体".equals(firePointQo.getLandtype())) {
|
||
return false;
|
||
}
|
||
if ("Himawari 8".equals(firePointQo.getSatelliteType())) {
|
||
if ("N".equals(firePointQo.getConfidence()) || "L".equals(firePointQo.getConfidence())) {
|
||
return false;
|
||
}
|
||
}
|
||
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.setSatelliteType(firePointQo.getSatelliteType());
|
||
firePointEntity.setLandType(firePointQo.getLandtype());
|
||
firePointEntity.setConfidence(firePointQo.getConfidence());
|
||
firePointEntity.setAddTime(dateTimeToString(LocalDateTime.now()));
|
||
firePointEntity.setFireType("0");
|
||
firePointEntity.setFireImage(firePointQo.getFireImage());
|
||
firePointEntity.setSatelliteImage(firePointQo.getSatelliteImage());
|
||
firePointEntity.setAuditFireType("0");//初始化火点为未审核状态
|
||
bindAddress(firePointEntity);
|
||
if (checkDuplicatedData(firePointEntity)) {
|
||
log.info("-------该火点和历史火点重复,不入库");
|
||
return false;
|
||
}
|
||
log.info("-------发现新火点");
|
||
firePointDao.save(firePointEntity);
|
||
forwardPoint(firePointEntity);
|
||
//发送消息通知
|
||
sendBroadcast(firePointEntity);
|
||
return true;
|
||
// if (firePointEntity.getCountyCode().startsWith("37")) {
|
||
// //如果开关已打开,就只将未审核的火点添加到山东临时表
|
||
// log.info("-------发现新山东火点");
|
||
// ShanDongFirePointEntity shanDongFirePointByFirePoint = getShanDongFirePointByFirePoint(firePointEntity);
|
||
// ShanDongFirePointEntity savedShanDongFirePoint = shanDongFirePointDao.save(shanDongFirePointByFirePoint);
|
||
// //微信消息通知火点审核工作组
|
||
// try {
|
||
// String messageContent = getMessageContent(savedShanDongFirePoint);
|
||
// WDWxSendMsgUtil.sendMsg("18447024917@chatroom", messageContent, 0);
|
||
// } catch (Exception e) {
|
||
// e.printStackTrace();
|
||
// }
|
||
// return true;
|
||
// }
|
||
}
|
||
|
||
private void forwardPoint(FirePointEntity firePointEntity) {
|
||
try {
|
||
String url = "http://121.36.229.60:6811/insertfirepointchannelThree";
|
||
HttpClientUtils.sendHttpPostTextPlain(url, new ObjectMapper().writeValueAsString(firePointEntity));
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 检查重复数据
|
||
*
|
||
* @param firePointEntity 待入库实体类
|
||
* @return true-是重复数据,拒绝入库;false-不是重复数据,可以入库
|
||
*/
|
||
private boolean checkDuplicatedData(FirePointEntity firePointEntity) {
|
||
List<FirePointEntity> duplicatedDataList = firePointDao.findDuplicatedData(firePointEntity.getLongitude(), firePointEntity.getLatitude(), firePointEntity.getStreetCode(), firePointEntity.getSatelliteTime(), firePointEntity.getSatelliteType(), firePointEntity.getLandType());
|
||
return duplicatedDataList != null && duplicatedDataList.size() > 0;
|
||
}
|
||
|
||
/**
|
||
* 根据山东火点生成全国火点
|
||
*/
|
||
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;
|
||
}
|
||
|
||
/**
|
||
* 为实体类绑定地址、编号、名称
|
||
*/
|
||
private void bindAddress(FirePointEntity firePointEntity) {
|
||
List<String> locationList = new ArrayList<>();
|
||
locationList.add(firePointEntity.getLongitude() + "," + firePointEntity.getLatitude());
|
||
GaoDeIgGeocodeVo geocode = GaoDeApiUtil.geocode(locationList);
|
||
GaoDeIgGeocodeVo.Regeocode reGeoCode = geocode.getRegeocodes().get(0);
|
||
String formattedAddress = reGeoCode.getFormatted_address();
|
||
firePointEntity.setFirePointAddress(formattedAddress);
|
||
GaoDeIgGeocodeVo.AddressComponent addressComponent = reGeoCode.getAddressComponent().get(0);
|
||
firePointEntity.setCountyCode(addressComponent.getAdcode());
|
||
firePointEntity.setCountyName(addressComponent.getDistrict());
|
||
String townCode = addressComponent.getTowncode();
|
||
String fixedTownCode = townCode.length() > 9 ? townCode.substring(0, 9) : townCode;
|
||
firePointEntity.setStreetCode(fixedTownCode);
|
||
firePointEntity.setStreetName(addressComponent.getTownship());
|
||
}
|
||
|
||
/**
|
||
* 根据火点编号更新审核状态
|
||
* 操作1:将火点编号对应的火点从山东火点表转存到火点表
|
||
* 操作2:将山东火点表中的这个火点的审核状态更新
|
||
*/
|
||
@Transactional(rollbackOn = Exception.class)
|
||
@Override
|
||
public String updateVerifyStateByFireCode(String fireCode, String verifyState) {
|
||
if ((!"0".equals(verifyState)) && (!"1".equals(verifyState)) && (!"2".equals(verifyState))) {
|
||
return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL, "审核失败,审核状态参数错误", locale);
|
||
}
|
||
ShanDongFirePointEntity existShanDongFirePoint = shanDongFirePointDao.findByFireCode(fireCode);
|
||
//山东火点表找不到这个火点,返回失败
|
||
if (existShanDongFirePoint == null) {
|
||
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "审核失败,没有指定的火点编号", locale);
|
||
}
|
||
if ("0".equals(existShanDongFirePoint.getVerifyState()) || "2".equals(existShanDongFirePoint.getVerifyState())) {
|
||
if ("0".equals(verifyState)) {
|
||
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "审核失败,审核状态不能被设置为未审核", locale);
|
||
}
|
||
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);
|
||
}
|
||
//操作2:将山东火点表中的这个火点的审核状态更新
|
||
shanDongFirePointDao.updateVerifyStateByFireCode(fireCode, verifyState);
|
||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale);
|
||
}
|
||
//0或者2可以被审核为1(未审核和未通过可以被审核为通过),已经通过了的就不能再处理了
|
||
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "审核失败,火点不能被重复审核", locale);
|
||
}
|
||
|
||
private void sendBroadcast(FirePointEntity firePointEntity) {
|
||
//发送微信群聊消息
|
||
sendWeChatGroupMessage(firePointEntity);
|
||
|
||
// if ("耕地".equals(firePointEntity.getLandType())) {
|
||
// //过滤短信通知收件人
|
||
// List<SysUserEntity> sysUserList = sysUserDao.findAll();
|
||
// boolean normalSmsEnable = 1L == globalConfigService.selectGlobalConfigValue(9L);
|
||
// boolean vipSmsEnable = 1L == globalConfigService.selectGlobalConfigValue(10L);
|
||
// List<SysUserEntity> smsReceiverList = FirePointCodeUtils.filterSmsReceiver(firePointEntity.getStreetCode(), sysUserList, normalSmsEnable, vipSmsEnable);
|
||
//// //推送
|
||
//// try {
|
||
//// List<String> userAccountList = pushHelper.obtainUserAccountList(smsReceiverList);
|
||
//// pushHelper.dispatchPushMessage(userAccountList, firePointEntity);
|
||
//// } catch (Exception e) {
|
||
//// e.printStackTrace();
|
||
//// }
|
||
// //对短信通知收件人进行分组
|
||
// List<AgentOrgEntity> agentOrgList = agentOrgDao.findAll();
|
||
// Map<String, List<SysUserEntity>> agentOrgNameGroupMap = FirePointCodeUtils.groupSmsReceiver(smsReceiverList, agentOrgList);
|
||
// //分发短信通知
|
||
// smsHelper.dispatchSMSMessage(agentOrgNameGroupMap, new String[]{firePointEntity.getFirePointAddress()}, new FirePointEntity[]{firePointEntity});
|
||
// }
|
||
}
|
||
|
||
/**
|
||
* 发送微信消息
|
||
*
|
||
* @param firePointEntity
|
||
*/
|
||
private void sendWeChatGroupMessage(FirePointEntity firePointEntity) {
|
||
List<CountyCodeWeiXinEntity> countyCodeWeiXinList = countyCodeWeiXinDao.findAll();
|
||
if (countyCodeWeiXinList.isEmpty()) {
|
||
return;
|
||
}
|
||
List<String> weixinIdList = new ArrayList<>();
|
||
for (CountyCodeWeiXinEntity countyCodeWeiXin : countyCodeWeiXinList) {
|
||
try {
|
||
if ((countyCodeWeiXin.getSendState() != null) && (countyCodeWeiXin.getSendState() != 0)) {
|
||
String formatCutCode = FirePointCodeUtils.getFormatCutCode(countyCodeWeiXin.getCountyCode());
|
||
if (firePointEntity.getStreetCode().startsWith(formatCutCode)) {
|
||
weixinIdList.add(countyCodeWeiXin.getWeixinId());
|
||
}
|
||
}
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
if (weixinIdList.size() > 0) {
|
||
StringBuilder stringBuilder = new StringBuilder("发送微信消息通知:\n");
|
||
String messageContent = getMessageContent(firePointEntity);
|
||
for (String weixinId : weixinIdList) {
|
||
stringBuilder.append(weixinId).append("\n");
|
||
try {
|
||
WDWxSendMsgUtil.sendMsg(weixinId, messageContent, 0);
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
stringBuilder.append("火情信息:").append(messageContent);
|
||
log.info(stringBuilder.toString());
|
||
}
|
||
}
|
||
|
||
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();
|
||
String streetName = firePointEntity.getStreetName();
|
||
String landType = firePointEntity.getLandType();
|
||
return firePointEntity.getSatelliteType() + "发现1个火点。\n卫星时间:" + satelliteTime + ";\nlongitude:" + formatLongitude + ";\nlatitude:" + formatLatitude + ";\ncountyName:" + countyName + ";\nstreetName:" + streetName + ";\nlandType:" + landType;
|
||
}
|
||
|
||
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();
|
||
String streetName = firePointEntity.getStreetName();
|
||
String landType = firePointEntity.getLandType();
|
||
return firePointEntity.getSatelliteType() + "发现1个待审核火点。\n卫星时间:" + satelliteTime + ";\nlongitude:" + formatLongitude + ";\nlatitude:" + formatLatitude + ";\ncountyName:" + countyName + ";\nstreetName:" + streetName + ";\nlandType:" + landType;
|
||
}
|
||
|
||
/**
|
||
* 下载VIP用户火点数据
|
||
*/
|
||
@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, "无数据!", locale);
|
||
}
|
||
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", locale);
|
||
}
|
||
|
||
@Override
|
||
public String downloadFirePoint(HttpServletRequest request, HttpServletResponse response, String ids) {
|
||
|
||
List<String> idList = ListUtils.toStringList(ids, ",");
|
||
if (idList.isEmpty()) {
|
||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "无数据!", locale);
|
||
}
|
||
List<Map<String, String>> list = new ArrayList<>();
|
||
List<FirePointEntity> sourceList = firePointDao.findAllById(ListUtils.stringListToLongList(idList));
|
||
for (FirePointEntity source : sourceList) {
|
||
Map<String, String> record = new HashMap<>();
|
||
record.put("所在区县", source.getCountyName());
|
||
record.put("所在街道", source.getStreetName());
|
||
record.put("发现时间", source.getSatelliteTime());
|
||
record.put("地物类型", source.getLandType());
|
||
record.put("经度", String.valueOf(source.getLongitude()));
|
||
record.put("纬度", String.valueOf(source.getLatitude()));
|
||
record.put("详细地址", source.getFirePointAddress());
|
||
list.add(record);
|
||
}
|
||
LocalDate now = LocalDate.now();
|
||
String fileName = String.format("%s_%s_%s_火点信息列表.xlsx", now.getYear(), now.getMonth().getValue(), now.getDayOfMonth());
|
||
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 fire point fail: {}", e.getMessage());
|
||
}
|
||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "ok", locale);
|
||
}
|
||
|
||
/**
|
||
* 动态多条件查询火点列表
|
||
*
|
||
* @param code 区划编码,可以是省市区县街道任意编码,如果传需要至少两位。不传代表查询全国火点
|
||
* @param startTime 过滤火点开始卫星时间,不传代表不指定开始时间。后台会有限制。
|
||
* @param endTime 过滤火点结束卫星时间,不传代表不指定结束时间。
|
||
* @param satelliteType 过滤传感器类型,不传代表查询全部类型的传感器
|
||
* @param landType 过滤地物类型,不传代表查询全部地物类型
|
||
* @return 符合条件的火点列表
|
||
*/
|
||
@Override
|
||
public List<FirePointEntity> queryFirePoint(String code, String startTime, String endTime, String satelliteType, String landType) {
|
||
return firePointQueryHelper.queryFirePoint(code, startTime, endTime, satelliteType, landType);
|
||
}
|
||
|
||
/**
|
||
* 查询今天的火点信息
|
||
*/
|
||
// @Cacheable(keyGenerator = "keyGenerator", unless = "#result == null")
|
||
@Override
|
||
public List<FirePointEntity> selectTodayFirePoint(String countyCode) {
|
||
|
||
LocalDateTime startTime1 = LocalDateTime.now();
|
||
LocalDateTime startTime2 = LocalDateTime.of(startTime1.getYear(), startTime1.getMonth(), startTime1.getDayOfMonth(), 0, 0, 0, 0);
|
||
String startTimeString = DateTimeUtils.localDateTimeToString(startTime2);
|
||
|
||
LocalDateTime endTime1 = LocalDateTime.now().plusDays(1);
|
||
LocalDateTime endTime2 = LocalDateTime.of(endTime1.getYear(), endTime1.getMonth(), endTime1.getDayOfMonth(), 0, 0, 0, 0);
|
||
String endTimeString = DateTimeUtils.localDateTimeToString(endTime2);
|
||
|
||
return firePointQueryHelper.queryFirePoint(countyCode, startTimeString, endTimeString, null, null);
|
||
}
|
||
|
||
/**
|
||
* 查询近一周的火点信息
|
||
*/
|
||
// @Cacheable(keyGenerator = "keyGenerator", unless = "#result == null")
|
||
@Override
|
||
public List<FirePointEntity> selectFirePointBetweenSeven() {
|
||
|
||
LocalDateTime startTime1 = LocalDateTime.now().minusDays(7);
|
||
LocalDateTime startTime2 = LocalDateTime.of(startTime1.getYear(), startTime1.getMonth(), startTime1.getDayOfMonth(), 0, 0, 0, 0);
|
||
String startTimeString = DateTimeUtils.localDateTimeToString(startTime2);
|
||
|
||
LocalDateTime endTime1 = LocalDateTime.now().plusDays(1);
|
||
LocalDateTime endTime2 = LocalDateTime.of(endTime1.getYear(), endTime1.getMonth(), endTime1.getDayOfMonth(), 0, 0, 0, 0);
|
||
String endTimeString = DateTimeUtils.localDateTimeToString(endTime2);
|
||
|
||
return firePointQueryHelper.queryFirePoint(null, startTimeString, endTimeString, null, null);
|
||
}
|
||
|
||
/**
|
||
* 查询近一个月的火点信息
|
||
*/
|
||
// @Cacheable(keyGenerator = "keyGenerator", unless = "#result == null")
|
||
@Override
|
||
public List<FirePointEntity> selectFirePointByMonth(String countyCode) {
|
||
|
||
// LocalDateTime startTime1 = LocalDateTime.now().minusMonths(1);
|
||
// LocalDateTime startTime2 = LocalDateTime.of(startTime1.getYear(), startTime1.getMonth(), startTime1.getDayOfMonth(), 0, 0, 0, 0);
|
||
// String startTimeString = DateTimeUtils.localDateTimeToString(startTime2);
|
||
//
|
||
// LocalDateTime endTime1 = LocalDateTime.now().plusDays(1);
|
||
// LocalDateTime endTime2 = LocalDateTime.of(endTime1.getYear(), endTime1.getMonth(), endTime1.getDayOfMonth(), 0, 0, 0, 0);
|
||
// String endTimeString = DateTimeUtils.localDateTimeToString(endTime2);
|
||
//
|
||
// return firePointQueryHelper.queryFirePoint(countyCode, startTimeString, endTimeString, null, null);
|
||
return firePointQueryHelper.queryFirePoint(countyCode, null, null, null, null);
|
||
}
|
||
|
||
/**
|
||
* 查询近一个月的火点数量
|
||
*
|
||
* @return
|
||
*/
|
||
// @Cacheable(keyGenerator = "keyGenerator", unless = "#result == null")
|
||
@Override
|
||
public String selectFirePointNumMonth() {
|
||
Map map = new HashMap(3);
|
||
LocalDateTime localDateTime = LocalDateTime.now();
|
||
LocalDateTime localDateTime2 = localDateTime.plusDays(1);
|
||
String endTime = dateTimeToString(localDateTime2);
|
||
// 当前时间减30
|
||
LocalDateTime localDateTime1 = localDateTime.minusDays(30);
|
||
String startTime = dateTimeToString(localDateTime1);
|
||
// 查询近一个月各植被类型的火点数量
|
||
List<Map<String, Object>> maps = firePointDao.selectNumByLandType(startTime, endTime);
|
||
map.put("land", maps);
|
||
// 查询近一个月各地区火点数量
|
||
List<Map<String, Object>> maps1 = firePointDao.selectNumByArea(startTime, endTime);
|
||
map.put("area", maps1);
|
||
|
||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, map, locale);
|
||
}
|
||
|
||
/**
|
||
* 查询近一天的火点数量
|
||
*
|
||
* @return
|
||
*/
|
||
// @Cacheable(keyGenerator = "keyGenerator", unless = "#result == null")
|
||
@Override
|
||
public String selectFirePointNumDay() {
|
||
Map map = new HashMap(3);
|
||
LocalDateTime localDateTime = LocalDateTime.now();
|
||
LocalDateTime localDateTime2 = localDateTime.plusDays(1);
|
||
String endTime = dateTimeToString(localDateTime2);
|
||
// 当前时间减1
|
||
LocalDateTime localDateTime1 = localDateTime.minusDays(1);
|
||
String startTime = dateTimeToString(localDateTime1);
|
||
// 查询近一个月各植被类型的火点数量
|
||
List<Map<String, Object>> maps = firePointDao.selectNumByLandType(startTime, endTime);
|
||
map.put("land", maps);
|
||
// 查询近一个月各地区火点数量
|
||
List<Map<String, Object>> maps1 = firePointDao.selectNumByArea(startTime, endTime);
|
||
map.put("area", maps1);
|
||
|
||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, map, locale);
|
||
}
|
||
|
||
/**
|
||
* 查询近一周的火点数量
|
||
*
|
||
* @return
|
||
*/
|
||
// @Cacheable(keyGenerator = "keyGenerator", unless = "#result == null")
|
||
@Override
|
||
public String selectFirePointNumWeek() {
|
||
Map map = new HashMap(3);
|
||
LocalDateTime localDateTime = LocalDateTime.now();
|
||
LocalDateTime localDateTime2 = localDateTime.plusDays(1);
|
||
String endTime = dateTimeToString(localDateTime2);
|
||
// 当前时间减7
|
||
LocalDateTime localDateTime1 = localDateTime.minusDays(7);
|
||
String startTime = dateTimeToString(localDateTime1);
|
||
// 查询近一个月各植被类型的火点数量
|
||
List<Map<String, Object>> maps = firePointDao.selectNumByLandType(startTime, endTime);
|
||
map.put("land", maps);
|
||
// 查询近一个月各地区火点数量
|
||
List<Map<String, Object>> maps1 = firePointDao.selectNumByArea(startTime, endTime);
|
||
map.put("area", maps1);
|
||
|
||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, map, locale);
|
||
}
|
||
|
||
}
|