火点重构-普通火点全部入库
This commit is contained in:
parent
bc8c492a36
commit
affcfbc474
@ -6,14 +6,11 @@ import com.xkrs.helper.FirePointPushManager;
|
|||||||
import com.xkrs.helper.FirePointQueryManager;
|
import com.xkrs.helper.FirePointQueryManager;
|
||||||
import com.xkrs.helper.GeoCodeHelper;
|
import com.xkrs.helper.GeoCodeHelper;
|
||||||
import com.xkrs.model.bean.DataWrapper2;
|
import com.xkrs.model.bean.DataWrapper2;
|
||||||
import com.xkrs.model.entity.FirePointChannelConfigEntity;
|
|
||||||
import com.xkrs.model.entity.FirePointOrdinaryEntity;
|
import com.xkrs.model.entity.FirePointOrdinaryEntity;
|
||||||
import com.xkrs.model.entity.FirePointPreciseEntity;
|
|
||||||
import com.xkrs.model.entity.StreetEntity;
|
import com.xkrs.model.entity.StreetEntity;
|
||||||
import com.xkrs.model.qo.AllFirePointQo;
|
import com.xkrs.model.qo.AllFirePointQo;
|
||||||
import com.xkrs.service.DispatchFirePointService;
|
import com.xkrs.service.DispatchFirePointService;
|
||||||
import com.xkrs.utilsnew.DateTimeUtils;
|
import com.xkrs.utilsnew.DateTimeUtils;
|
||||||
import com.xkrs.utilsnew.FirePointDispatchUtils;
|
|
||||||
import com.xkrs.utilsnew.FirePointFilterUtils;
|
import com.xkrs.utilsnew.FirePointFilterUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -23,7 +20,6 @@ import org.springframework.stereotype.Service;
|
|||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZoneOffset;
|
import java.time.ZoneOffset;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
|
import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
|
||||||
@ -71,8 +67,6 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.info("insertFirePointChannelOrdinary 接收到火点信息:" + firePointQo.toString());
|
log.info("insertFirePointChannelOrdinary 接收到火点信息:" + firePointQo.toString());
|
||||||
String messageOrdinary = "";
|
|
||||||
String messagePrecise = "";
|
|
||||||
|
|
||||||
String fireCode = firePointQo.getFireCode();
|
String fireCode = firePointQo.getFireCode();
|
||||||
Long satelliteTimeTs = firePointQo.getSatelliteTimeTs();
|
Long satelliteTimeTs = firePointQo.getSatelliteTimeTs();
|
||||||
@ -91,75 +85,34 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService {
|
|||||||
String satelliteTime = DateTimeUtils.localDateTimeToString(satelliteLocalDateTime);//卫星时间
|
String satelliteTime = DateTimeUtils.localDateTimeToString(satelliteLocalDateTime);//卫星时间
|
||||||
String addTime = DateTimeUtils.localDateTimeToString(LocalDateTime.now());//添加时间
|
String addTime = DateTimeUtils.localDateTimeToString(LocalDateTime.now());//添加时间
|
||||||
|
|
||||||
//普通渠道来的火点直接入库普通火点库
|
FirePointOrdinaryEntity firePointOrdinaryEntity = new FirePointOrdinaryEntity();
|
||||||
{
|
firePointOrdinaryEntity.setFireCode(fireCode);
|
||||||
FirePointOrdinaryEntity firePointOrdinaryEntity = new FirePointOrdinaryEntity();
|
firePointOrdinaryEntity.setSatelliteTime(satelliteTime);
|
||||||
firePointOrdinaryEntity.setFireCode(fireCode);
|
firePointOrdinaryEntity.setLongitude(longitude);
|
||||||
firePointOrdinaryEntity.setSatelliteTime(satelliteTime);
|
firePointOrdinaryEntity.setLatitude(latitude);
|
||||||
firePointOrdinaryEntity.setLongitude(longitude);
|
firePointOrdinaryEntity.setSatelliteType(satelliteType);
|
||||||
firePointOrdinaryEntity.setLatitude(latitude);
|
firePointOrdinaryEntity.setLandType(landType);
|
||||||
firePointOrdinaryEntity.setSatelliteType(satelliteType);
|
firePointOrdinaryEntity.setConfidence(confidence);
|
||||||
firePointOrdinaryEntity.setLandType(landType);
|
firePointOrdinaryEntity.setFireImage(fireImage);
|
||||||
firePointOrdinaryEntity.setConfidence(confidence);
|
firePointOrdinaryEntity.setSatelliteImage(satelliteImage);
|
||||||
firePointOrdinaryEntity.setFireImage(fireImage);
|
firePointOrdinaryEntity.setAddTime(addTime);
|
||||||
firePointOrdinaryEntity.setSatelliteImage(satelliteImage);
|
StreetEntity streetEntity = obtainInfoByCountyCode(countyCode);
|
||||||
firePointOrdinaryEntity.setAddTime(addTime);
|
if (streetEntity != null) {
|
||||||
StreetEntity streetEntity = obtainInfoByCountyCode(countyCode);
|
firePointOrdinaryEntity.setProCode(streetEntity.getProCode());
|
||||||
if (streetEntity != null) {
|
firePointOrdinaryEntity.setProName(streetEntity.getProName());
|
||||||
firePointOrdinaryEntity.setProCode(streetEntity.getProCode());
|
firePointOrdinaryEntity.setCityCode(streetEntity.getCityCode());
|
||||||
firePointOrdinaryEntity.setProName(streetEntity.getProName());
|
firePointOrdinaryEntity.setCityName(streetEntity.getCityName());
|
||||||
firePointOrdinaryEntity.setCityCode(streetEntity.getCityCode());
|
|
||||||
firePointOrdinaryEntity.setCityName(streetEntity.getCityName());
|
|
||||||
}
|
|
||||||
firePointOrdinaryEntity.setCountyCode(countyCode);
|
|
||||||
firePointOrdinaryEntity.setCountyName(countyName);
|
|
||||||
firePointOrdinaryEntity.setTownCode(townCode);
|
|
||||||
bindFirePointAddress(firePointOrdinaryEntity);
|
|
||||||
DataWrapper2<Boolean, String> checkDuplicatedWrapper1 = FirePointFilterUtils.checkDuplicated(firePointOrdinaryDao, firePointOrdinaryEntity);
|
|
||||||
if (checkDuplicatedWrapper1.getData1()) {
|
|
||||||
messageOrdinary = checkDuplicatedWrapper1.getData2();
|
|
||||||
} else {
|
|
||||||
messageOrdinary = "普通火点添加成功";
|
|
||||||
firePointOrdinaryDao.save(firePointOrdinaryEntity);
|
|
||||||
// firePointPushManager.pushNotification(firePointOrdinaryEntity);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
List<FirePointChannelConfigEntity> firePointChannelConfigEntityList = channelConfigDao.findAll();
|
firePointOrdinaryEntity.setCountyCode(countyCode);
|
||||||
boolean inPreciseTimeRange = FirePointDispatchUtils.ifInFireSeason(fireCode, satelliteLocalDateTime, firePointChannelConfigEntityList);
|
firePointOrdinaryEntity.setCountyName(countyName);
|
||||||
//如果现在不属于精准渠道的时间范围,那么普通渠道来的火点就入库精准火点库
|
firePointOrdinaryEntity.setTownCode(townCode);
|
||||||
if (!inPreciseTimeRange) {
|
bindFirePointAddress(firePointOrdinaryEntity);
|
||||||
FirePointPreciseEntity firePointPreciseEntity = new FirePointPreciseEntity();
|
DataWrapper2<Boolean, String> checkDuplicatedWrapper1 = FirePointFilterUtils.checkDuplicated(firePointOrdinaryDao, firePointOrdinaryEntity);
|
||||||
firePointPreciseEntity.setFireCode(fireCode);
|
if (checkDuplicatedWrapper1.getData1()) {
|
||||||
firePointPreciseEntity.setSatelliteTime(satelliteTime);
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, checkDuplicatedWrapper1.getData2(), locale);
|
||||||
firePointPreciseEntity.setLongitude(longitude);
|
|
||||||
firePointPreciseEntity.setLatitude(latitude);
|
|
||||||
firePointPreciseEntity.setSatelliteType(satelliteType);
|
|
||||||
firePointPreciseEntity.setLandType(landType);
|
|
||||||
firePointPreciseEntity.setConfidence(confidence);
|
|
||||||
firePointPreciseEntity.setFireImage(fireImage);
|
|
||||||
firePointPreciseEntity.setSatelliteImage(satelliteImage);
|
|
||||||
firePointPreciseEntity.setAddTime(addTime);
|
|
||||||
StreetEntity streetEntity = obtainInfoByCountyCode(countyCode);
|
|
||||||
if (streetEntity != null) {
|
|
||||||
firePointPreciseEntity.setProCode(streetEntity.getProCode());
|
|
||||||
firePointPreciseEntity.setProName(streetEntity.getProName());
|
|
||||||
firePointPreciseEntity.setCityCode(streetEntity.getCityCode());
|
|
||||||
firePointPreciseEntity.setCityName(streetEntity.getCityName());
|
|
||||||
}
|
|
||||||
firePointPreciseEntity.setCountyCode(countyCode);
|
|
||||||
firePointPreciseEntity.setCountyName(countyName);
|
|
||||||
firePointPreciseEntity.setTownCode(townCode);
|
|
||||||
bindFirePointAddress(firePointPreciseEntity);
|
|
||||||
DataWrapper2<Boolean, String> checkDuplicatedWrapper2 = FirePointFilterUtils.checkDuplicated(firePointPreciseDao, firePointPreciseEntity);
|
|
||||||
if (checkDuplicatedWrapper2.getData1()) {
|
|
||||||
messagePrecise = checkDuplicatedWrapper2.getData2();
|
|
||||||
} else {
|
|
||||||
messagePrecise = "审核火点添加成功";
|
|
||||||
firePointPreciseDao.save(firePointPreciseEntity);
|
|
||||||
firePointPushManager.pushNotification(firePointPreciseEntity);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, messageOrdinary + messagePrecise, locale);
|
firePointOrdinaryDao.save(firePointOrdinaryEntity);
|
||||||
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "添加成功", locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
private StreetEntity obtainInfoByCountyCode(String countyCode) {
|
private StreetEntity obtainInfoByCountyCode(String countyCode) {
|
||||||
@ -176,100 +129,7 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String insertFirePointChannelPrecise(AllFirePointQo firePointQo) {
|
public String insertFirePointChannelPrecise(AllFirePointQo firePointQo) {
|
||||||
DataWrapper2<Boolean, String> checkLandTypeWrapper = FirePointFilterUtils.checkLandType(firePointQo.getLandtype());
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "", locale);
|
||||||
if (!checkLandTypeWrapper.getData1()) {
|
|
||||||
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, checkLandTypeWrapper.getData2(), locale);
|
|
||||||
}
|
|
||||||
DataWrapper2<Boolean, String> checkSatelliteTypeWrapper = FirePointFilterUtils.checkSatelliteType(firePointQo.getSatelliteType(), firePointQo.getConfidence());
|
|
||||||
if (!checkSatelliteTypeWrapper.getData1()) {
|
|
||||||
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, checkSatelliteTypeWrapper.getData2(), locale);
|
|
||||||
}
|
|
||||||
|
|
||||||
log.info("insertFirePointChannelPrecise 接收到火点信息:" + firePointQo.toString());
|
|
||||||
String messagePrecise = "";
|
|
||||||
|
|
||||||
String fireCode = firePointQo.getFireCode();
|
|
||||||
Long satelliteTimeTs = firePointQo.getSatelliteTimeTs();
|
|
||||||
Double longitude = firePointQo.getLongitude();
|
|
||||||
Double latitude = firePointQo.getLatitude();
|
|
||||||
String satelliteType = firePointQo.getSatelliteType();
|
|
||||||
String landType = firePointQo.getLandtype();
|
|
||||||
String confidence = firePointQo.getConfidence();
|
|
||||||
String fireImage = firePointQo.getFireImage();
|
|
||||||
String satelliteImage = firePointQo.getSatelliteImage();
|
|
||||||
String countyCode = String.valueOf(firePointQo.getCountyCode());
|
|
||||||
String countyName = firePointQo.getCountyName();
|
|
||||||
String townCode = firePointQo.getTowncode();
|
|
||||||
|
|
||||||
LocalDateTime satelliteLocalDateTime = LocalDateTime.ofEpochSecond(satelliteTimeTs, 0, ZoneOffset.ofHours(8));
|
|
||||||
String satelliteTime = DateTimeUtils.localDateTimeToString(satelliteLocalDateTime);//卫星时间
|
|
||||||
String addTime = DateTimeUtils.localDateTimeToString(LocalDateTime.now());//添加时间
|
|
||||||
|
|
||||||
List<FirePointChannelConfigEntity> firePointChannelConfigEntityList = channelConfigDao.findAll();
|
|
||||||
boolean inPreciseTimeRange = FirePointDispatchUtils.ifInFireSeason(fireCode, satelliteLocalDateTime, firePointChannelConfigEntityList);
|
|
||||||
//如果现在属于精准渠道的时间范围,那么精准渠道来的火点就入库精准火点库
|
|
||||||
if (inPreciseTimeRange) {
|
|
||||||
FirePointPreciseEntity firePointPreciseEntity = new FirePointPreciseEntity();
|
|
||||||
firePointPreciseEntity.setFireCode(fireCode);
|
|
||||||
firePointPreciseEntity.setSatelliteTime(satelliteTime);
|
|
||||||
firePointPreciseEntity.setLongitude(longitude);
|
|
||||||
firePointPreciseEntity.setLatitude(latitude);
|
|
||||||
firePointPreciseEntity.setSatelliteType(satelliteType);
|
|
||||||
firePointPreciseEntity.setLandType(landType);
|
|
||||||
firePointPreciseEntity.setConfidence(confidence);
|
|
||||||
firePointPreciseEntity.setFireImage(fireImage);
|
|
||||||
firePointPreciseEntity.setSatelliteImage(satelliteImage);
|
|
||||||
firePointPreciseEntity.setAddTime(addTime);
|
|
||||||
StreetEntity streetEntity = obtainInfoByCountyCode(countyCode);
|
|
||||||
if (streetEntity != null) {
|
|
||||||
firePointPreciseEntity.setProCode(streetEntity.getProCode());
|
|
||||||
firePointPreciseEntity.setProName(streetEntity.getProName());
|
|
||||||
firePointPreciseEntity.setCityCode(streetEntity.getCityCode());
|
|
||||||
firePointPreciseEntity.setCityName(streetEntity.getCityName());
|
|
||||||
}
|
|
||||||
firePointPreciseEntity.setCountyCode(countyCode);
|
|
||||||
firePointPreciseEntity.setCountyName(countyName);
|
|
||||||
firePointPreciseEntity.setTownCode(townCode);
|
|
||||||
bindFirePointAddress(firePointPreciseEntity);
|
|
||||||
DataWrapper2<Boolean, String> checkDuplicatedWrapper2 = FirePointFilterUtils.checkDuplicated(firePointPreciseDao, firePointPreciseEntity);
|
|
||||||
if (checkDuplicatedWrapper2.getData1()) {
|
|
||||||
messagePrecise = checkDuplicatedWrapper2.getData2();
|
|
||||||
} else {
|
|
||||||
messagePrecise = "审核火点添加成功";
|
|
||||||
firePointPreciseDao.save(firePointPreciseEntity);
|
|
||||||
firePointPushManager.pushNotification(firePointPreciseEntity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, messagePrecise, locale);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 绑定火点位置
|
|
||||||
* 如果能接收到TownCode(山东省内),会判断CountyCode、CountyName、TownCode,
|
|
||||||
* 如果不能接收到TownCode(其他省份),会判断CountyCode、CountyName,
|
|
||||||
* <p>
|
|
||||||
* 如果根据经纬度反算出来的变量都一致,就更新TownCode、TownName、FirePointAddress,无备注。
|
|
||||||
* 如果不一致,就只更新FirePointAddress,备注存储差异信息
|
|
||||||
*/
|
|
||||||
private void bindFirePointAddress(FirePointPreciseEntity firePointPreciseEntity) {
|
|
||||||
String countyCode = firePointPreciseEntity.getCountyCode();
|
|
||||||
String countyName = firePointPreciseEntity.getCountyName();
|
|
||||||
String townCode = firePointPreciseEntity.getTownCode();
|
|
||||||
GeoCodeHelper geoCodeHelper = new GeoCodeHelper();
|
|
||||||
geoCodeHelper.doGeoCode(firePointPreciseEntity.getLongitude(), firePointPreciseEntity.getLatitude());
|
|
||||||
boolean geoCodeResult = geoCodeHelper.checkGeoCodeResult(countyCode, countyName, townCode);
|
|
||||||
if (geoCodeResult) {
|
|
||||||
firePointPreciseEntity.setTownCode(geoCodeHelper.getCalTownCode());
|
|
||||||
firePointPreciseEntity.setTownName(geoCodeHelper.getCalTownName());
|
|
||||||
firePointPreciseEntity.setFirePointAddress(geoCodeHelper.getCalFirePointAddress());
|
|
||||||
firePointPreciseEntity.setRemark("");
|
|
||||||
} else {
|
|
||||||
firePointPreciseEntity.setTownCode(geoCodeHelper.getCalTownCode());
|
|
||||||
firePointPreciseEntity.setTownName(geoCodeHelper.getCalTownName());
|
|
||||||
firePointPreciseEntity.setFirePointAddress(geoCodeHelper.getCalFirePointAddress());
|
|
||||||
String remark = "接收到的countyCode=" + countyCode + ",计算得到的countyCode=" + geoCodeHelper.getCalCountyCode() + "。接收到的countyName=" + countyName + ",计算得到的countyName=" + geoCodeHelper.getCalCountyName() + "。接收到的townCode=" + townCode + ",计算得到的townCode=" + geoCodeHelper.getCalTownCode() + "。";
|
|
||||||
firePointPreciseEntity.setRemark(remark);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user