diff --git a/src/main/java/com/xkrs/straw/model/bean/DataWrapper.java b/src/main/java/com/xkrs/straw/model/bean/DataWrapper.java new file mode 100644 index 0000000..2749ec4 --- /dev/null +++ b/src/main/java/com/xkrs/straw/model/bean/DataWrapper.java @@ -0,0 +1,22 @@ +package com.xkrs.straw.model.bean; + +public class DataWrapper { + + private DataType data; + + public DataWrapper() { + } + + public DataWrapper(DataType data) { + this.data = data; + } + + public DataType getData() { + return data; + } + + public DataWrapper setData(DataType data) { + this.data = data; + return this; + } +} diff --git a/src/main/java/com/xkrs/straw/model/bean/DataWrapper2.java b/src/main/java/com/xkrs/straw/model/bean/DataWrapper2.java new file mode 100644 index 0000000..713552a --- /dev/null +++ b/src/main/java/com/xkrs/straw/model/bean/DataWrapper2.java @@ -0,0 +1,33 @@ +package com.xkrs.straw.model.bean; + +public class DataWrapper2 { + + 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 setData1(DataType1 data1) { + this.data1 = data1; + return this; + } + + public DataType2 getData2() { + return data2; + } + + public DataWrapper2 setData2(DataType2 data2) { + this.data2 = data2; + return this; + } +} diff --git a/src/main/java/com/xkrs/straw/model/bean/DataWrapper3.java b/src/main/java/com/xkrs/straw/model/bean/DataWrapper3.java new file mode 100644 index 0000000..3498640 --- /dev/null +++ b/src/main/java/com/xkrs/straw/model/bean/DataWrapper3.java @@ -0,0 +1,44 @@ +package com.xkrs.straw.model.bean; + +public class DataWrapper3 { + + 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 setData1(DataType1 data1) { + this.data1 = data1; + return this; + } + + public DataType2 getData2() { + return data2; + } + + public DataWrapper3 setData2(DataType2 data2) { + this.data2 = data2; + return this; + } + + public DataType3 getData3() { + return data3; + } + + public DataWrapper3 setData3(DataType3 data3) { + this.data3 = data3; + return this; + } +} diff --git a/src/main/java/com/xkrs/straw/model/bean/DataWrapper4.java b/src/main/java/com/xkrs/straw/model/bean/DataWrapper4.java new file mode 100644 index 0000000..f2f638b --- /dev/null +++ b/src/main/java/com/xkrs/straw/model/bean/DataWrapper4.java @@ -0,0 +1,55 @@ +package com.xkrs.straw.model.bean; + +public class DataWrapper4 { + + 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 setData1(DataType1 data1) { + this.data1 = data1; + return this; + } + + public DataType2 getData2() { + return data2; + } + + public DataWrapper4 setData2(DataType2 data2) { + this.data2 = data2; + return this; + } + + public DataType3 getData3() { + return data3; + } + + public DataWrapper4 setData3(DataType3 data3) { + this.data3 = data3; + return this; + } + + public DataType4 getData4() { + return data4; + } + + public DataWrapper4 setData4(DataType4 data4) { + this.data4 = data4; + return this; + } +} diff --git a/src/main/java/com/xkrs/straw/service/impl/DispatchFirePointServiceImpl.java b/src/main/java/com/xkrs/straw/service/impl/DispatchFirePointServiceImpl.java index cd99a64..cdfd39d 100644 --- a/src/main/java/com/xkrs/straw/service/impl/DispatchFirePointServiceImpl.java +++ b/src/main/java/com/xkrs/straw/service/impl/DispatchFirePointServiceImpl.java @@ -6,12 +6,14 @@ import com.xkrs.straw.dao.FirePointOrdinaryDao; import com.xkrs.straw.dao.FirePointPreciseDao; import com.xkrs.straw.dao.SysUserDao; 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.FirePointOrdinaryEntity; import com.xkrs.straw.model.entity.FirePointPreciseEntity; import com.xkrs.straw.model.qo.AllFirePointQo; import com.xkrs.straw.service.DispatchFirePointService; import com.xkrs.straw.utils.DispatchFirePointUtils; +import com.xkrs.straw.utils.FirePointFilterUtils; import com.xkrs.straw.utils.FirePointQueryManager; import com.xkrs.utils.DateTimeUtils; import org.slf4j.Logger; @@ -54,7 +56,18 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService { */ @Override public String insertFirePointChannelOrdinary(AllFirePointQo firePointQo) { + DataWrapper2 checkLandTypeWrapper = FirePointFilterUtils.checkLandType(firePointQo.getLandType()); + if (!checkLandTypeWrapper.getData1()) { + return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, checkLandTypeWrapper.getData2(), locale); + } + DataWrapper2 checkSatelliteTypeWrapper = FirePointFilterUtils.checkSatelliteType(firePointQo.getSatelliteType(), firePointQo.getConfidence()); + if (!checkSatelliteTypeWrapper.getData1()) { + return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, checkSatelliteTypeWrapper.getData2(), locale); + } + log.info("insertFirePointChannelOrdinary 接收到火点信息:" + firePointQo.toString()); + String messageOrdinary = ""; + String messagePrecise = ""; String fireCode = firePointQo.getFireCode(); Long countyCode = firePointQo.getCountyCode(); @@ -89,8 +102,13 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService { firePointOrdinaryEntity.setTownCode(townCode); firePointOrdinaryEntity.setAddTime(addTime); bindFirePointAddress(firePointOrdinaryEntity); - firePointOrdinaryDao.save(firePointOrdinaryEntity); - + DataWrapper2 checkDuplicatedWrapper1 = FirePointFilterUtils.checkDuplicated(firePointOrdinaryDao, firePointOrdinaryEntity); + if (checkDuplicatedWrapper1.getData1()) { + messageOrdinary = checkDuplicatedWrapper1.getData2(); + } else { + messageOrdinary = "普通火点添加成功"; + firePointOrdinaryDao.save(firePointOrdinaryEntity); + } List firePointChannelConfigEntityList = channelConfigDao.findAll(); boolean inPreciseTimeRange = DispatchFirePointUtils.checkIfInPreciseTimeRange(fireCode, satelliteLocalDateTime, firePointChannelConfigEntityList); //如果现在不属于精准渠道的时间范围,那么普通渠道来的火点就入库精准火点库 @@ -110,10 +128,15 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService { firePointPreciseEntity.setTownCode(townCode); firePointPreciseEntity.setAddTime(addTime); bindFirePointAddress(firePointPreciseEntity); - firePointPreciseDao.save(firePointPreciseEntity); + DataWrapper2 checkDuplicatedWrapper2 = FirePointFilterUtils.checkDuplicated(firePointPreciseDao, firePointPreciseEntity); + if (checkDuplicatedWrapper2.getData1()) { + messagePrecise = checkDuplicatedWrapper2.getData2(); + } else { + messagePrecise = "审核火点添加成功"; + firePointPreciseDao.save(firePointPreciseEntity); + } } - - return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "添加成功", locale); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, messageOrdinary + messagePrecise, locale); } /** @@ -121,7 +144,17 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService { */ @Override public String insertFirePointChannelPrecise(AllFirePointQo firePointQo) { + DataWrapper2 checkLandTypeWrapper = FirePointFilterUtils.checkLandType(firePointQo.getLandType()); + if (!checkLandTypeWrapper.getData1()) { + return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, checkLandTypeWrapper.getData2(), locale); + } + DataWrapper2 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 countyCode = firePointQo.getCountyCode(); @@ -159,10 +192,15 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService { firePointPreciseEntity.setTownCode(townCode); firePointPreciseEntity.setAddTime(addTime); bindFirePointAddress(firePointPreciseEntity); - firePointPreciseDao.save(firePointPreciseEntity); + DataWrapper2 checkDuplicatedWrapper2 = FirePointFilterUtils.checkDuplicated(firePointPreciseDao, firePointPreciseEntity); + if (checkDuplicatedWrapper2.getData1()) { + messagePrecise = checkDuplicatedWrapper2.getData2(); + } else { + messagePrecise = "审核火点添加成功"; + firePointPreciseDao.save(firePointPreciseEntity); + } } - - return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "添加成功", locale); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, messagePrecise, locale); } /** diff --git a/src/main/java/com/xkrs/straw/utils/FirePointFilterUtils.java b/src/main/java/com/xkrs/straw/utils/FirePointFilterUtils.java new file mode 100644 index 0000000..288f41e --- /dev/null +++ b/src/main/java/com/xkrs/straw/utils/FirePointFilterUtils.java @@ -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 checkLandType(String landType) { + if ("水体".equals(landType)) { + return new DataWrapper2<>(Boolean.FALSE, "添加失败,不接收水体类型"); + } + return new DataWrapper2<>(Boolean.TRUE, ""); + } + + public static DataWrapper2 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 checkDuplicated(FirePointOrdinaryDao firePointOrdinaryDao, FirePointOrdinaryEntity firePointOrdinaryEntity) { + + return null; + } + + + public static DataWrapper2 checkDuplicated(FirePointPreciseDao firePointPreciseDao, FirePointPreciseEntity firePointPreciseEntity) { + + return null; + } +}