火点重构-普通火点全部入库

This commit is contained in:
liuchengqian 2023-03-29 10:42:34 +08:00
parent bc8c492a36
commit affcfbc474

View File

@ -6,14 +6,11 @@ import com.xkrs.helper.FirePointPushManager;
import com.xkrs.helper.FirePointQueryManager;
import com.xkrs.helper.GeoCodeHelper;
import com.xkrs.model.bean.DataWrapper2;
import com.xkrs.model.entity.FirePointChannelConfigEntity;
import com.xkrs.model.entity.FirePointOrdinaryEntity;
import com.xkrs.model.entity.FirePointPreciseEntity;
import com.xkrs.model.entity.StreetEntity;
import com.xkrs.model.qo.AllFirePointQo;
import com.xkrs.service.DispatchFirePointService;
import com.xkrs.utilsnew.DateTimeUtils;
import com.xkrs.utilsnew.FirePointDispatchUtils;
import com.xkrs.utilsnew.FirePointFilterUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -23,7 +20,6 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.List;
import java.util.Locale;
import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
@ -71,8 +67,6 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService {
}
log.info("insertFirePointChannelOrdinary 接收到火点信息:" + firePointQo.toString());
String messageOrdinary = "";
String messagePrecise = "";
String fireCode = firePointQo.getFireCode();
Long satelliteTimeTs = firePointQo.getSatelliteTimeTs();
@ -91,8 +85,6 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService {
String satelliteTime = DateTimeUtils.localDateTimeToString(satelliteLocalDateTime);//卫星时间
String addTime = DateTimeUtils.localDateTimeToString(LocalDateTime.now());//添加时间
//普通渠道来的火点直接入库普通火点库
{
FirePointOrdinaryEntity firePointOrdinaryEntity = new FirePointOrdinaryEntity();
firePointOrdinaryEntity.setFireCode(fireCode);
firePointOrdinaryEntity.setSatelliteTime(satelliteTime);
@ -117,49 +109,10 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService {
bindFirePointAddress(firePointOrdinaryEntity);
DataWrapper2<Boolean, String> checkDuplicatedWrapper1 = FirePointFilterUtils.checkDuplicated(firePointOrdinaryDao, firePointOrdinaryEntity);
if (checkDuplicatedWrapper1.getData1()) {
messageOrdinary = checkDuplicatedWrapper1.getData2();
} else {
messageOrdinary = "普通火点添加成功";
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, checkDuplicatedWrapper1.getData2(), locale);
}
firePointOrdinaryDao.save(firePointOrdinaryEntity);
// firePointPushManager.pushNotification(firePointOrdinaryEntity);
}
}
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, messageOrdinary + messagePrecise, locale);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "添加成功", locale);
}
private StreetEntity obtainInfoByCountyCode(String countyCode) {
@ -176,100 +129,7 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService {
*/
@Override
public String insertFirePointChannelPrecise(AllFirePointQo firePointQo) {
DataWrapper2<Boolean, String> checkLandTypeWrapper = FirePointFilterUtils.checkLandType(firePointQo.getLandtype());
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山东省内会判断CountyCodeCountyNameTownCode
* 如果不能接收到TownCode其他省份会判断CountyCodeCountyName
* <p>
* 如果根据经纬度反算出来的变量都一致就更新TownCodeTownNameFirePointAddress无备注
* 如果不一致就只更新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);
}
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "", locale);
}
/**