From aa3f2560e7fc0cbc25bebb65895c4cf585460de7 Mon Sep 17 00:00:00 2001 From: "DESKTOP-G8BCEP0\\HP" <2037158277@qq.com> Date: Thu, 23 Sep 2021 16:36:08 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E4=BF=AE=E6=94=B9=E4=BA=86=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E5=A4=9A=E6=9D=A1=E4=BB=B6=E6=9F=A5=E8=AF=A2=E5=B8=82?= =?UTF-8?q?=E7=9A=84=E5=8A=9F=E8=83=BD=E6=A8=A1=E5=9D=97=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=BA=86=E5=85=B6=E4=B8=AD=20=E7=9A=84=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E5=B8=82=E5=90=8D=E7=A7=B0=E7=9A=84sql=E8=AF=AD?= =?UTF-8?q?=E5=8F=A5=202=E3=80=81=E6=B7=BB=E5=8A=A0=E4=BA=86=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E6=8F=92=E5=85=A5=E7=81=AB=E7=82=B9=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E7=9A=84=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xkrs/common/config/WebSecurityConfig.java | 1 + .../xkrs/controller/FirePointController.java | 18 ++ src/main/java/com/xkrs/dao/FireDao.java | 13 + .../java/com/xkrs/model/entity/FirePoint.java | 258 ++++++++++++++++++ .../com/xkrs/service/FirePointService.java | 8 + .../service/impl/FirePointServiceImpl.java | 32 ++- 6 files changed, 329 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/xkrs/dao/FireDao.java create mode 100644 src/main/java/com/xkrs/model/entity/FirePoint.java diff --git a/src/main/java/com/xkrs/common/config/WebSecurityConfig.java b/src/main/java/com/xkrs/common/config/WebSecurityConfig.java index 601e796..84ac9a6 100644 --- a/src/main/java/com/xkrs/common/config/WebSecurityConfig.java +++ b/src/main/java/com/xkrs/common/config/WebSecurityConfig.java @@ -57,6 +57,7 @@ class WebSecurityConfig extends WebSecurityConfigurerAdapter { .antMatchers(HttpMethod.GET,"/api/user/verificationCode").permitAll() .antMatchers(HttpMethod.POST,"/uploadFileMore").permitAll() .antMatchers(HttpMethod.POST,"/uploadFile").permitAll() + .antMatchers(HttpMethod.POST,"/insertFireTest").permitAll() // 所有其它请求需要身份认证 .anyRequest().authenticated() .and() diff --git a/src/main/java/com/xkrs/controller/FirePointController.java b/src/main/java/com/xkrs/controller/FirePointController.java index 6c89e75..f26e2ec 100644 --- a/src/main/java/com/xkrs/controller/FirePointController.java +++ b/src/main/java/com/xkrs/controller/FirePointController.java @@ -5,6 +5,7 @@ import com.xkrs.common.tool.TokenUtil; import com.xkrs.dao.FirePointDao; import com.xkrs.dao.SysUserDao; import com.xkrs.model.entity.CountyEntity; +import com.xkrs.model.entity.FirePoint; import com.xkrs.model.entity.FirePointEntity; import com.xkrs.model.entity.SysUserEntity; import com.xkrs.model.qo.FirePointQo; @@ -275,4 +276,21 @@ public class FirePointController { FirePointEntity byFireCode = firePointDao.findByFireCode(fireCode); return outputEncapsulationObject(PromptMessageEnum.SUCCESS,byFireCode,locale); } + + /** + * 测试添加火点信息 + * @param firePointQo + * @return + */ + @PostMapping("/insertFireTest") + public String insertFireTest(@RequestBody FirePointQo firePointQo){ + // 获取区域信息 + Locale locale = LocaleContextHolder.getLocale(); + FirePoint firePoint = firePointService.insertFireTest(firePointQo); + if(firePoint == null){ + return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL,"添加数据失败",locale); + }else { + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"添加成功",locale); + } + } } diff --git a/src/main/java/com/xkrs/dao/FireDao.java b/src/main/java/com/xkrs/dao/FireDao.java new file mode 100644 index 0000000..4b60f4e --- /dev/null +++ b/src/main/java/com/xkrs/dao/FireDao.java @@ -0,0 +1,13 @@ +package com.xkrs.dao; + +import com.xkrs.model.entity.FirePoint; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Component; + +/** + * @author XinYi Song + */ +@Component +public interface FireDao extends JpaRepository { + +} diff --git a/src/main/java/com/xkrs/model/entity/FirePoint.java b/src/main/java/com/xkrs/model/entity/FirePoint.java new file mode 100644 index 0000000..77df8bf --- /dev/null +++ b/src/main/java/com/xkrs/model/entity/FirePoint.java @@ -0,0 +1,258 @@ +package com.xkrs.model.entity; + +import javax.persistence.*; + +/** + * @author XinYi Song + */ +@Entity +@Table(name="fire") +public class FirePoint { + /** + * 指定主键,建立自增序列,主键值取自序列 + */ + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "fire_seq_gen") + @SequenceGenerator(name = "fire_seq_gen", sequenceName = "fire_id_seq",allocationSize = 1) + private Integer id; + + /** + * 火点编码 + */ + @Column( length = 32,unique = true,columnDefinition = "varchar(32)") + private String fireCode; + + /** + * 经度 + */ + private double longitude; + + /** + * 纬度 + */ + private double latitude; + + /** + * 省市区的编码 + */ + @Column(length = 32, columnDefinition = "varchar(32)") + private String countyCode; + + /** + * 省市区的名称 + */ + @Column( columnDefinition = "varchar(64)") + private String countyName; + + /** + * 卫星监测的时间 + */ + private String satelliteTime; + + /** + * 卫星的类型 + */ + @Column( columnDefinition = "varchar(64)") + private String satelliteType; + + /** + * 植被类型 + */ + @Column( columnDefinition = "varchar(64)") + private String landType; + + /** + * 添加的时间 + */ + private String addTime; + + /** + * 置信度 + */ + @Column(length = 32, columnDefinition = "varchar(32)") + private String confidence; + + /** + * 详细地址 + */ + private String firePointAddress; + + /** + * 火点状态 0 发现 1预警 2核查 -1,3结案 + */ + @Column(length = 32, columnDefinition = "varchar(32)") + private String fireType; + + /** + * 当前火点的图片 + */ + private String fireImage; + + /** + * 卫星影像图片 + */ + private String satelliteImage; + + + public FirePoint() { + } + + public FirePoint(Integer id, String fireCode, double longitude, double latitude, String countyCode, String countyName, String satelliteTime, String satelliteType, String landType, String addTime, String confidence, String firePointAddress, String fireType, String fireImage, String satelliteImage) { + this.id = id; + this.fireCode = fireCode; + this.longitude = longitude; + this.latitude = latitude; + this.countyCode = countyCode; + this.countyName = countyName; + this.satelliteTime = satelliteTime; + this.satelliteType = satelliteType; + this.landType = landType; + this.addTime = addTime; + this.confidence = confidence; + this.firePointAddress = firePointAddress; + this.fireType = fireType; + this.fireImage = fireImage; + this.satelliteImage = satelliteImage; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getFireCode() { + return fireCode; + } + + public void setFireCode(String fireCode) { + this.fireCode = fireCode; + } + + public double getLongitude() { + return longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public double getLatitude() { + return latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public String getCountyCode() { + return countyCode; + } + + public void setCountyCode(String countyCode) { + this.countyCode = countyCode; + } + + public String getCountyName() { + return countyName; + } + + public void setCountyName(String countyName) { + this.countyName = countyName; + } + + public String getSatelliteTime() { + return satelliteTime; + } + + public void setSatelliteTime(String satelliteTime) { + this.satelliteTime = satelliteTime; + } + + public String getSatelliteType() { + return satelliteType; + } + + public void setSatelliteType(String satelliteType) { + this.satelliteType = satelliteType; + } + + public String getLandType() { + return landType; + } + + public void setLandType(String landType) { + this.landType = landType; + } + + public String getAddTime() { + return addTime; + } + + public void setAddTime(String addTime) { + this.addTime = addTime; + } + + public String getConfidence() { + return confidence; + } + + public void setConfidence(String confidence) { + this.confidence = confidence; + } + + public String getFirePointAddress() { + return firePointAddress; + } + + public void setFirePointAddress(String firePointAddress) { + this.firePointAddress = firePointAddress; + } + + public String getFireType() { + return fireType; + } + + public void setFireType(String fireType) { + this.fireType = fireType; + } + + public String getFireImage() { + return fireImage; + } + + public void setFireImage(String fireImage) { + this.fireImage = fireImage; + } + + public String getSatelliteImage() { + return satelliteImage; + } + + public void setSatelliteImage(String satelliteImage) { + this.satelliteImage = satelliteImage; + } + + @Override + public String toString() { + return "FirePointEntity{" + + "id=" + id + + ", fireCode='" + fireCode + '\'' + + ", longitude=" + longitude + + ", latitude=" + latitude + + ", countyCode='" + countyCode + '\'' + + ", countyName='" + countyName + '\'' + + ", satelliteTime='" + satelliteTime + '\'' + + ", satelliteType='" + satelliteType + '\'' + + ", landType='" + landType + '\'' + + ", addTime='" + addTime + '\'' + + ", confidence='" + confidence + '\'' + + ", firePointAddress='" + firePointAddress + '\'' + + ", fireType='" + fireType + '\'' + + ", fireImage='" + fireImage + '\'' + + ", satelliteImage='" + satelliteImage + '\'' + + '}'; + } +} diff --git a/src/main/java/com/xkrs/service/FirePointService.java b/src/main/java/com/xkrs/service/FirePointService.java index f6f2294..22816e5 100644 --- a/src/main/java/com/xkrs/service/FirePointService.java +++ b/src/main/java/com/xkrs/service/FirePointService.java @@ -1,6 +1,7 @@ package com.xkrs.service; import com.xkrs.dao.FirePointDao; +import com.xkrs.model.entity.FirePoint; import com.xkrs.model.entity.FirePointEntity; import com.xkrs.model.qo.FirePointQo; import com.xkrs.model.vo.AppTaskBodyVo; @@ -135,4 +136,11 @@ public interface FirePointService { * @return */ List> selectCountyName(String code); + + /** + * 测试插入火点信息 + * @param firePointQo + * @return + */ + FirePoint insertFireTest(FirePointQo firePointQo); } diff --git a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java index b1c47c5..56b911e 100644 --- a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java @@ -66,6 +66,9 @@ public class FirePointServiceImpl implements FirePointService { @Resource private CountyDao countyDao; + @Resource + private FireDao fireDao; + /** * 添加火点信息 * @param firePointQo @@ -158,7 +161,8 @@ public class FirePointServiceImpl implements FirePointService { */ @Override public List selectFirePointByCity(String cityCodeOne, String cityCode, String satelliteType, String landType, String startTime, String endTime) { - List byCityCode = cityDao.findByCityCode(cityCodeOne); + //List byCityCode = cityDao.findByCityCode(cityCodeOne.substring(0,3)); + List byCityCode = countyDao.findByCityCode(cityCodeOne); String cityName = byCityCode.get(0).getCityName(); return query.selectFirePointByCity(cityName,cityCode,satelliteType,landType,startTime,endTime); } @@ -427,4 +431,30 @@ public class FirePointServiceImpl implements FirePointService { public List> selectCountyName(String code) { return countyDao.selectCountyName(code); } + + /** + * 测试插入火点信息 + * @param firePointQo + * @return + */ + @Override + public FirePoint insertFireTest(FirePointQo firePointQo) { + FirePoint firePoint = new FirePoint(); + firePoint.setFireCode(firePointQo.getFireCode()); + firePoint.setCountyCode(firePointQo.getCountyCode().toString()); + firePoint.setCountyName(firePointQo.getCountyName()); + firePoint.setSatelliteTime(DateTimeUtil.timeMillisToString(firePointQo.getSatelliteTimeTs().longValue())); + firePoint.setLongitude(firePointQo.getLongitude()); + firePoint.setLatitude(firePointQo.getLatitude()); + firePoint.setFirePointAddress(AddressUtils.getLocal(firePointQo.getLatitude().toString(),firePointQo.getLongitude().toString())); + firePoint.setSatelliteType(firePointQo.getSatelliteType()); + firePoint.setLandType(firePointQo.getLandtype()); + firePoint.setConfidence(firePointQo.getConfidence()); + firePoint.setAddTime(DateTimeUtil.dateTimeToString(LocalDateTime.now())); + firePoint.setFireType("0"); + firePoint.setFireImage(firePointQo.getFireImage()); + firePoint.setSatelliteImage(firePointQo.getSatelliteImage()); + log.info("-------发现新火点"); + return fireDao.save(firePoint); + } }