This commit is contained in:
liuchengqian 2023-03-04 16:26:23 +08:00
parent e5164f4766
commit 6ae858f827
6 changed files with 240 additions and 8 deletions

View File

@ -0,0 +1,22 @@
package com.xkrs.straw.model.bean;
public class DataWrapper<DataType> {
private DataType data;
public DataWrapper() {
}
public DataWrapper(DataType data) {
this.data = data;
}
public DataType getData() {
return data;
}
public DataWrapper<DataType> setData(DataType data) {
this.data = data;
return this;
}
}

View File

@ -0,0 +1,33 @@
package com.xkrs.straw.model.bean;
public class DataWrapper2<DataType1, DataType2> {
private DataType1 data1;
private DataType2 data2;
public DataWrapper2() {
}
public DataWrapper2(DataType1 data1, DataType2 data2) {
this.data1 = data1;
this.data2 = data2;
}
public DataType1 getData1() {
return data1;
}
public DataWrapper2<DataType1, DataType2> setData1(DataType1 data1) {
this.data1 = data1;
return this;
}
public DataType2 getData2() {
return data2;
}
public DataWrapper2<DataType1, DataType2> setData2(DataType2 data2) {
this.data2 = data2;
return this;
}
}

View File

@ -0,0 +1,44 @@
package com.xkrs.straw.model.bean;
public class DataWrapper3<DataType1, DataType2, DataType3> {
private DataType1 data1;
private DataType2 data2;
private DataType3 data3;
public DataWrapper3() {
}
public DataWrapper3(DataType1 data1, DataType2 data2, DataType3 data3) {
this.data1 = data1;
this.data2 = data2;
this.data3 = data3;
}
public DataType1 getData1() {
return data1;
}
public DataWrapper3<DataType1, DataType2, DataType3> setData1(DataType1 data1) {
this.data1 = data1;
return this;
}
public DataType2 getData2() {
return data2;
}
public DataWrapper3<DataType1, DataType2, DataType3> setData2(DataType2 data2) {
this.data2 = data2;
return this;
}
public DataType3 getData3() {
return data3;
}
public DataWrapper3<DataType1, DataType2, DataType3> setData3(DataType3 data3) {
this.data3 = data3;
return this;
}
}

View File

@ -0,0 +1,55 @@
package com.xkrs.straw.model.bean;
public class DataWrapper4<DataType1, DataType2, DataType3, DataType4> {
private DataType1 data1;
private DataType2 data2;
private DataType3 data3;
private DataType4 data4;
public DataWrapper4() {
}
public DataWrapper4(DataType1 data1, DataType2 data2, DataType3 data3, DataType4 data4) {
this.data1 = data1;
this.data2 = data2;
this.data3 = data3;
this.data4 = data4;
}
public DataType1 getData1() {
return data1;
}
public DataWrapper4<DataType1, DataType2, DataType3, DataType4> setData1(DataType1 data1) {
this.data1 = data1;
return this;
}
public DataType2 getData2() {
return data2;
}
public DataWrapper4<DataType1, DataType2, DataType3, DataType4> setData2(DataType2 data2) {
this.data2 = data2;
return this;
}
public DataType3 getData3() {
return data3;
}
public DataWrapper4<DataType1, DataType2, DataType3, DataType4> setData3(DataType3 data3) {
this.data3 = data3;
return this;
}
public DataType4 getData4() {
return data4;
}
public DataWrapper4<DataType1, DataType2, DataType3, DataType4> setData4(DataType4 data4) {
this.data4 = data4;
return this;
}
}

View File

@ -6,12 +6,14 @@ import com.xkrs.straw.dao.FirePointOrdinaryDao;
import com.xkrs.straw.dao.FirePointPreciseDao; import com.xkrs.straw.dao.FirePointPreciseDao;
import com.xkrs.straw.dao.SysUserDao; import com.xkrs.straw.dao.SysUserDao;
import com.xkrs.straw.helper.GeoCodeHelper; import com.xkrs.straw.helper.GeoCodeHelper;
import com.xkrs.straw.model.bean.DataWrapper2;
import com.xkrs.straw.model.entity.FirePointChannelConfigEntity; import com.xkrs.straw.model.entity.FirePointChannelConfigEntity;
import com.xkrs.straw.model.entity.FirePointOrdinaryEntity; import com.xkrs.straw.model.entity.FirePointOrdinaryEntity;
import com.xkrs.straw.model.entity.FirePointPreciseEntity; import com.xkrs.straw.model.entity.FirePointPreciseEntity;
import com.xkrs.straw.model.qo.AllFirePointQo; import com.xkrs.straw.model.qo.AllFirePointQo;
import com.xkrs.straw.service.DispatchFirePointService; import com.xkrs.straw.service.DispatchFirePointService;
import com.xkrs.straw.utils.DispatchFirePointUtils; import com.xkrs.straw.utils.DispatchFirePointUtils;
import com.xkrs.straw.utils.FirePointFilterUtils;
import com.xkrs.straw.utils.FirePointQueryManager; import com.xkrs.straw.utils.FirePointQueryManager;
import com.xkrs.utils.DateTimeUtils; import com.xkrs.utils.DateTimeUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -54,7 +56,18 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService {
*/ */
@Override @Override
public String insertFirePointChannelOrdinary(AllFirePointQo firePointQo) { public String insertFirePointChannelOrdinary(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("insertFirePointChannelOrdinary 接收到火点信息:" + firePointQo.toString()); log.info("insertFirePointChannelOrdinary 接收到火点信息:" + firePointQo.toString());
String messageOrdinary = "";
String messagePrecise = "";
String fireCode = firePointQo.getFireCode(); String fireCode = firePointQo.getFireCode();
Long countyCode = firePointQo.getCountyCode(); Long countyCode = firePointQo.getCountyCode();
@ -89,8 +102,13 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService {
firePointOrdinaryEntity.setTownCode(townCode); firePointOrdinaryEntity.setTownCode(townCode);
firePointOrdinaryEntity.setAddTime(addTime); firePointOrdinaryEntity.setAddTime(addTime);
bindFirePointAddress(firePointOrdinaryEntity); bindFirePointAddress(firePointOrdinaryEntity);
firePointOrdinaryDao.save(firePointOrdinaryEntity); DataWrapper2<Boolean, String> checkDuplicatedWrapper1 = FirePointFilterUtils.checkDuplicated(firePointOrdinaryDao, firePointOrdinaryEntity);
if (checkDuplicatedWrapper1.getData1()) {
messageOrdinary = checkDuplicatedWrapper1.getData2();
} else {
messageOrdinary = "普通火点添加成功";
firePointOrdinaryDao.save(firePointOrdinaryEntity);
}
List<FirePointChannelConfigEntity> firePointChannelConfigEntityList = channelConfigDao.findAll(); List<FirePointChannelConfigEntity> firePointChannelConfigEntityList = channelConfigDao.findAll();
boolean inPreciseTimeRange = DispatchFirePointUtils.checkIfInPreciseTimeRange(fireCode, satelliteLocalDateTime, firePointChannelConfigEntityList); boolean inPreciseTimeRange = DispatchFirePointUtils.checkIfInPreciseTimeRange(fireCode, satelliteLocalDateTime, firePointChannelConfigEntityList);
//如果现在不属于精准渠道的时间范围那么普通渠道来的火点就入库精准火点库 //如果现在不属于精准渠道的时间范围那么普通渠道来的火点就入库精准火点库
@ -110,10 +128,15 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService {
firePointPreciseEntity.setTownCode(townCode); firePointPreciseEntity.setTownCode(townCode);
firePointPreciseEntity.setAddTime(addTime); firePointPreciseEntity.setAddTime(addTime);
bindFirePointAddress(firePointPreciseEntity); bindFirePointAddress(firePointPreciseEntity);
firePointPreciseDao.save(firePointPreciseEntity); DataWrapper2<Boolean, String> checkDuplicatedWrapper2 = FirePointFilterUtils.checkDuplicated(firePointPreciseDao, firePointPreciseEntity);
if (checkDuplicatedWrapper2.getData1()) {
messagePrecise = checkDuplicatedWrapper2.getData2();
} else {
messagePrecise = "审核火点添加成功";
firePointPreciseDao.save(firePointPreciseEntity);
}
} }
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, messageOrdinary + messagePrecise, locale);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "添加成功", locale);
} }
/** /**
@ -121,7 +144,17 @@ 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());
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()); log.info("insertFirePointChannelPrecise 接收到火点信息:" + firePointQo.toString());
String messagePrecise = "";
String fireCode = firePointQo.getFireCode(); String fireCode = firePointQo.getFireCode();
Long countyCode = firePointQo.getCountyCode(); Long countyCode = firePointQo.getCountyCode();
@ -159,10 +192,15 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService {
firePointPreciseEntity.setTownCode(townCode); firePointPreciseEntity.setTownCode(townCode);
firePointPreciseEntity.setAddTime(addTime); firePointPreciseEntity.setAddTime(addTime);
bindFirePointAddress(firePointPreciseEntity); bindFirePointAddress(firePointPreciseEntity);
firePointPreciseDao.save(firePointPreciseEntity); DataWrapper2<Boolean, String> checkDuplicatedWrapper2 = FirePointFilterUtils.checkDuplicated(firePointPreciseDao, firePointPreciseEntity);
if (checkDuplicatedWrapper2.getData1()) {
messagePrecise = checkDuplicatedWrapper2.getData2();
} else {
messagePrecise = "审核火点添加成功";
firePointPreciseDao.save(firePointPreciseEntity);
}
} }
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, messagePrecise, locale);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "添加成功", locale);
} }
/** /**

View File

@ -0,0 +1,40 @@
package com.xkrs.straw.utils;
import com.xkrs.straw.dao.FirePointOrdinaryDao;
import com.xkrs.straw.dao.FirePointPreciseDao;
import com.xkrs.straw.model.bean.DataWrapper2;
import com.xkrs.straw.model.entity.FirePointOrdinaryEntity;
import com.xkrs.straw.model.entity.FirePointPreciseEntity;
public class FirePointFilterUtils {
private FirePointFilterUtils() {
}
public static DataWrapper2<Boolean, String> checkLandType(String landType) {
if ("水体".equals(landType)) {
return new DataWrapper2<>(Boolean.FALSE, "添加失败,不接收水体类型");
}
return new DataWrapper2<>(Boolean.TRUE, "");
}
public static DataWrapper2<Boolean, String> checkSatelliteType(String satelliteType, String confidence) {
if ("Himawari 8".equals(satelliteType)) {
if ("N".equals(confidence) || "L".equals(confidence)) {
return new DataWrapper2<>(Boolean.FALSE, "添加失败不接收葵花8中低置信度火点");
}
}
return new DataWrapper2<>(Boolean.TRUE, "");
}
public static DataWrapper2<Boolean, String> checkDuplicated(FirePointOrdinaryDao firePointOrdinaryDao, FirePointOrdinaryEntity firePointOrdinaryEntity) {
return null;
}
public static DataWrapper2<Boolean, String> checkDuplicated(FirePointPreciseDao firePointPreciseDao, FirePointPreciseEntity firePointPreciseEntity) {
return null;
}
}